2015-12-16 22:43:33 +00:00
|
|
|
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
|
|
|
|
2015-12-16 22:43:33 +00:00
|
|
|
ContactService.getAll().then(function(contacts) {
|
|
|
|
$scope.$apply(function(){
|
|
|
|
ctrl.contacts = contacts;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
ctrl.createContact = function() {
|
2016-01-21 12:28:52 +00:00
|
|
|
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
|
|
|
}]);
|