In my controller, I have data like:
$scope.object = data
Now this data is the dictionary with keys and values from json
.
I can acce
A todo list example which loops over object by ng-repeat
:
var app = angular.module('toDolistApp', []);
app.controller('toDoListCntrl', function() {
var self = this;
self.toDoListItems = {};// []; //dont use square brackets if keys are string rather than numbers.
self.doListCounter = 0;
self.addToDoList = function() {
var newToDoItem = {};
newToDoItem.title = self.toDoEntry;
newToDoItem.completed = false;
var keyIs = "key_" + self.doListCounter++;
self.toDoListItems[keyIs] = newToDoItem;
self.toDoEntry = ""; //after adding the item make the input box blank.
};
});
app.filter('propsCounter', function() {
return function(input) {
return Object.keys(input).length;
}
});
Total Items: {{toDoListCntrlAs.toDoListItems | propsCounter}}
Enter todo Item:
{{toDoListCntrlAs.toDoEntry}}
{{$index+1}} : {{key}} : Title = {{ prop.title}} : Status = {{ prop.completed}}