How to display selected contact using pickContact() - ionic-v3


#1

Hello, i want display selected contact detail in input, in alert showing contact details. so i want display that contact detail in my form. any idea how to do…please help!

home.ts

import { Contact, ContactField, ContactName, Contacts } from '@ionic-native/contacts';
: 
constructor(public navCtrl: NavController, public navParams: NavParams, private contacts: Contacts) {
this.contacts.pickContact().then((contact)=>{
        alert("contacts:-->"+ JSON.stringify(contact));
      });
}

home.html

<ion-content padding>
    <form (ngSubmit)="saveItem()" ng-controller="AppCtrl">
        <ion-item>
            <ion-label>Name</ion-label>
            <ion-input type="text" [(ngModel)]="contact.displayName" name="displayName"></ion-input>
        </ion-item>
        <ion-item>
            <ion-label>Phone</ion-label>
            <ion-input type="tel" [(ngModel)]="contact.phoneNumbers" name="phoneNumbers"></ion-input>
        </ion-item>
        <ion-item>
            <ion-label>Birth</ion-label>
            <ion-datetime displayFormat="DD/MM/YYYY" [(ngModel)]="contact.birthday" name="birthday"></ion-datetime>
        </ion-item>
</form>
</ion-content>