Calling method from a Angular 2 class inside template

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';
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)