2016-02-15 12:42:26 +00:00
|
|
|
app.controller('contactdetailsCtrl', ['ContactService', '$routeParams', '$scope', function(ContactService, $routeParams, $scope) {
|
2015-11-05 15:33:30 +00:00
|
|
|
var ctrl = this;
|
2016-01-13 20:14:14 +00:00
|
|
|
|
2016-02-15 12:42:26 +00:00
|
|
|
ctrl.uid = $routeParams.uid;
|
2016-02-24 19:54:35 +00:00
|
|
|
ctrl.t = {
|
|
|
|
'noContacts' : t('contactsrework', 'No contacts in here')
|
|
|
|
};
|
2016-02-15 12:42:26 +00:00
|
|
|
|
|
|
|
$scope.$watch('ctrl.uid', function(newValue, oldValue) {
|
|
|
|
ctrl.changeContact(newValue);
|
|
|
|
});
|
|
|
|
|
|
|
|
ctrl.changeContact = function(uid) {
|
2016-02-17 21:34:36 +00:00
|
|
|
if (typeof uid === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-15 12:42:26 +00:00
|
|
|
ContactService.getById(uid).then(function(contact) {
|
|
|
|
ctrl.contact = contact;
|
2016-02-22 20:34:10 +00:00
|
|
|
ctrl.singleProperties = ctrl.contact.getSingleProperties();
|
2016-02-24 15:28:47 +00:00
|
|
|
ctrl.photo = ctrl.contact.photo();
|
2016-02-15 12:42:26 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-01-14 10:36:41 +00:00
|
|
|
ctrl.updateContact = function() {
|
2016-01-21 12:28:52 +00:00
|
|
|
ContactService.update(ctrl.contact);
|
2016-01-14 10:36:41 +00:00
|
|
|
console.log('updating Contact');
|
|
|
|
};
|
|
|
|
|
2016-01-13 20:14:14 +00:00
|
|
|
ctrl.deleteContact = function() {
|
2016-02-11 14:30:52 +00:00
|
|
|
ContactService.delete(ctrl.contact);
|
2016-01-13 20:14:14 +00:00
|
|
|
console.log('Deleting Contact');
|
|
|
|
};
|
|
|
|
}]);
|