contacts/js/components/contactList/contactList_controller.js

38 lines
843 B
JavaScript
Raw Normal View History

2016-02-17 21:34:36 +00:00
app.controller('contactlistCtrl', ['$scope', 'ContactService', '$routeParams', function($scope, ContactService, $routeParams) {
2015-10-27 17:52:09 +00:00
var ctrl = this;
2015-12-08 11:31:43 +00:00
ctrl.routeParams = $routeParams;
2016-02-24 19:54:35 +00:00
ctrl.t = {
addContact : t('contactsrework', 'Add contact')
};
2016-02-17 21:34:36 +00:00
2016-02-11 14:30:52 +00:00
ContactService.registerObserverCallback(function(contacts) {
$scope.$apply(function() {
ctrl.contacts = contacts;
});
});
ContactService.getAll().then(function(contacts) {
$scope.$apply(function(){
ctrl.contacts = contacts;
});
});
ctrl.createContact = function() {
2016-02-11 14:30:52 +00:00
ContactService.create();
2016-01-14 10:40:45 +00:00
};
2016-02-18 16:46:06 +00:00
2016-02-18 21:07:10 +00:00
ctrl.hasContacts = function () {
if (!ctrl.contacts) {
return false;
}
return ctrl.contacts.length > 0;
};
2016-02-18 16:58:00 +00:00
$scope.selectedContactId = $routeParams.uid;
2016-02-18 16:46:06 +00:00
$scope.setSelected = function (selectedContactId) {
$scope.selectedContactId = selectedContactId;
};
2015-12-08 11:31:43 +00:00
}]);