In my HTML template I have the following:
<a ng-href="{{ person | personLink }}">
person is set in the controller as:
$scope.person = Person.get({examId: $routeParams.personId});
and Person is a resource:
app.factory('Person', [
'$resource', function($resource) {
return $resource('/api/people/:personId/', {
personId: '@personId'});
}
]);
The problem is the filter gets called before the promise is ready and results in reading undefined values. What is the correct way to deal with this?
Right now I use an if check on the attribute, but this does not seem ideal:
renderFilters.filter('personLink', function() {
return function(person) {
if(person.ages) {
return '#/ages/' + person.ages;
}else{
return '#';
}
};
});