Either you call the method like this:
{{user.name()}} // instead of {{user.name}}
For this approach you need to be aware that you will lose the execution context (this
). See this question for more details:
- ng-lightning – data object is undefined on lookup
Or you define your method as a getter so you can use user.name
in your template:
get name() {
if (this.deleted_at === null) {
return this.first_name;
} else {
return 'DELETED';
}
}