Reputation: 115
I have in my controller:
$scope.items = myItems;
var myItems = [{title=""}]
but on my view nothing gets displayed, if i set the $scope.items to equal the list it works fine. Eventually i want to be able to change the list used when i user clicks a div on my view. i will be using this statement to switch
$scope.toggle = function (tog) {
if (tog == 0) {
$scope.items = myItems;
} else if (tog == 1) {
$scope.items = companyItems;
};
};
Upvotes: 1
Views: 313
Reputation: 21694
You have a syntax error, it should be :
and not =
inside the object. So:
var myItems = [{title:""}]
Second, when you assign it in the order you do, myItems
is not defined yet when assigning into the scope variable, so your value would be undefined
. (at least in the initial run, after the $scope.toggle
function is called, it will be okay. Just switch the 2 top lines around
Upvotes: 5