I have a angular 2 application that has a class called User. This user has a attribute called deleted_at that is either null or contains a datetime, obviously the user is de
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:
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';
}
}