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;
};
};
1 Answer 1
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,
myItemsis not defined yet when assigning into the scope variable, so your value would beundefined. (at least in the initial run, after the$scope.togglefunction is called, it will be okay. Just switch the 2 top lines around
var myItems = [{title=""}]var myItems = [{title:""}]$scope.itemsbefore assigning tomyItems, so$scope.itemsis undefined