contacts/js/components/contactList/contactList_controller.js

18 lines
432 B
JavaScript
Raw Normal View History

app.controller('contactlistCtrl', ['$scope', 'ContactService', 'Contact', function($scope, ContactService, Contact) {
2015-10-27 17:52:09 +00:00
var ctrl = this;
2015-12-08 11:31:43 +00:00
ContactService.getAll().then(function(contacts) {
$scope.$apply(function(){
ctrl.contacts = contacts;
});
});
ctrl.createContact = function() {
ContactService.create().then(function(newContact){
$scope.$apply(function(){
ctrl.contacts.push(newContact);
});
});
2016-01-14 10:40:45 +00:00
};
2015-12-08 11:31:43 +00:00
}]);