Call function from template


#1

I have my component where I export my “Page”.
Inside that class i’ve got a function and i’m trying to call it from the template of that page:

public getContactNameNumber = function(number) {
    this.contacts.find(['phoneNumbers'], {filter: number, multiple: false})
    .then(data => {
      if(data && data[0]) {
        let contact = data[0];

        console.log(contact.displayName);
        return contact.displayName;
      }

      return number;
    });
  }
<ion-item *ngFor='let message of messages'>
      <div class="message-detail">
        To: {{ getContactNameNumber(message.to) }}<br>
      </div>
</ion-item>

So my console.log() return the right value but what happen is that i continue to see that console.log() in my console and I didn’t get any value in my template.

Where i’m wrong?