I have an Angular application that get a 'person' from a rest call. In the config I have:
when('/people/edit/:id',{
controller:PersonEditCtrl,
templateUrl: 'frontend/partials/people/person.html',
resolve: {
person: function(Restangular, $route){
var theRoute= 'people/' + $route.current.params.id + '/';
return Restangular.one(theRoute).get();
}
}
}).
In the controller:
function PersonEditCtrl($scope, $location, Restangular, person) {
$scope.person = person;
}
In the html page, I use like this to show info:
{{person.firstName}}
In the html page, I would like to add some behavior to 'person'. For instance, I'd like to add a function that combines the first and last name. So, I'd like a function like getFullName(). Note that I am not making a person object, I am only getting the JSON from a ReST call. I'm assuming the a person object is getting made somehow, but I do not know how.
How do I add functions/methods to 'person' in how I currently have things?