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












1















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>









share|improve this question

























  • Simply assign model to selected contact response.

    – Khurshid Ansari
    Nov 28 '18 at 20:14
















1















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>









share|improve this question

























  • Simply assign model to selected contact response.

    – Khurshid Ansari
    Nov 28 '18 at 20:14














1












1








1








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>









share|improve this question
















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>






ionic3 ionic-native






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '18 at 5:04









Khurshid Ansari

672617




672617










asked Nov 28 '18 at 12:18









user9088454user9088454

10210




10210













  • Simply assign model to selected contact response.

    – Khurshid Ansari
    Nov 28 '18 at 20:14



















  • Simply assign model to selected contact response.

    – Khurshid Ansari
    Nov 28 '18 at 20:14

















Simply assign model to selected contact response.

– Khurshid Ansari
Nov 28 '18 at 20:14





Simply assign model to selected contact response.

– Khurshid Ansari
Nov 28 '18 at 20:14












1 Answer
1






active

oldest

votes


















1














Try



contact = {
displayName:null,
phoneNumbers:null,
birthday:null
};

selectContact(){
this.contacts.pickContact().then((contact)=>{
alert("contacts:-->"+ JSON.stringify(contact));
this.contact.displayName = contact.displayName;
this.contact.phoneNumbers = contact.phoneNumbers[0].value;
contact.birthday = contact.birthday;
});
}


Note : property name check and assign from response.






share|improve this answer


























  • one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

    – user9088454
    Nov 29 '18 at 7:17













  • I think mobile number input not accepting value, try change input type or remove input type.

    – Khurshid Ansari
    Nov 29 '18 at 8:25











  • this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

    – user9088454
    Nov 29 '18 at 9:30








  • 1





    check my answer. you are not able to assign value properly.

    – Khurshid Ansari
    Nov 29 '18 at 10:48






  • 1





    now everything working perfect...thanks boss

    – user9088454
    Nov 29 '18 at 11:35











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519328%2fhow-to-display-selected-contact-using-pickcontact-ionic-v3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Try



contact = {
displayName:null,
phoneNumbers:null,
birthday:null
};

selectContact(){
this.contacts.pickContact().then((contact)=>{
alert("contacts:-->"+ JSON.stringify(contact));
this.contact.displayName = contact.displayName;
this.contact.phoneNumbers = contact.phoneNumbers[0].value;
contact.birthday = contact.birthday;
});
}


Note : property name check and assign from response.






share|improve this answer


























  • one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

    – user9088454
    Nov 29 '18 at 7:17













  • I think mobile number input not accepting value, try change input type or remove input type.

    – Khurshid Ansari
    Nov 29 '18 at 8:25











  • this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

    – user9088454
    Nov 29 '18 at 9:30








  • 1





    check my answer. you are not able to assign value properly.

    – Khurshid Ansari
    Nov 29 '18 at 10:48






  • 1





    now everything working perfect...thanks boss

    – user9088454
    Nov 29 '18 at 11:35
















1














Try



contact = {
displayName:null,
phoneNumbers:null,
birthday:null
};

selectContact(){
this.contacts.pickContact().then((contact)=>{
alert("contacts:-->"+ JSON.stringify(contact));
this.contact.displayName = contact.displayName;
this.contact.phoneNumbers = contact.phoneNumbers[0].value;
contact.birthday = contact.birthday;
});
}


Note : property name check and assign from response.






share|improve this answer


























  • one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

    – user9088454
    Nov 29 '18 at 7:17













  • I think mobile number input not accepting value, try change input type or remove input type.

    – Khurshid Ansari
    Nov 29 '18 at 8:25











  • this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

    – user9088454
    Nov 29 '18 at 9:30








  • 1





    check my answer. you are not able to assign value properly.

    – Khurshid Ansari
    Nov 29 '18 at 10:48






  • 1





    now everything working perfect...thanks boss

    – user9088454
    Nov 29 '18 at 11:35














1












1








1







Try



contact = {
displayName:null,
phoneNumbers:null,
birthday:null
};

selectContact(){
this.contacts.pickContact().then((contact)=>{
alert("contacts:-->"+ JSON.stringify(contact));
this.contact.displayName = contact.displayName;
this.contact.phoneNumbers = contact.phoneNumbers[0].value;
contact.birthday = contact.birthday;
});
}


Note : property name check and assign from response.






share|improve this answer















Try



contact = {
displayName:null,
phoneNumbers:null,
birthday:null
};

selectContact(){
this.contacts.pickContact().then((contact)=>{
alert("contacts:-->"+ JSON.stringify(contact));
this.contact.displayName = contact.displayName;
this.contact.phoneNumbers = contact.phoneNumbers[0].value;
contact.birthday = contact.birthday;
});
}


Note : property name check and assign from response.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 29 '18 at 11:49









user9088454

10210




10210










answered Nov 28 '18 at 20:23









Khurshid AnsariKhurshid Ansari

672617




672617













  • one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

    – user9088454
    Nov 29 '18 at 7:17













  • I think mobile number input not accepting value, try change input type or remove input type.

    – Khurshid Ansari
    Nov 29 '18 at 8:25











  • this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

    – user9088454
    Nov 29 '18 at 9:30








  • 1





    check my answer. you are not able to assign value properly.

    – Khurshid Ansari
    Nov 29 '18 at 10:48






  • 1





    now everything working perfect...thanks boss

    – user9088454
    Nov 29 '18 at 11:35



















  • one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

    – user9088454
    Nov 29 '18 at 7:17













  • I think mobile number input not accepting value, try change input type or remove input type.

    – Khurshid Ansari
    Nov 29 '18 at 8:25











  • this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

    – user9088454
    Nov 29 '18 at 9:30








  • 1





    check my answer. you are not able to assign value properly.

    – Khurshid Ansari
    Nov 29 '18 at 10:48






  • 1





    now everything working perfect...thanks boss

    – user9088454
    Nov 29 '18 at 11:35

















one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

– user9088454
Nov 29 '18 at 7:17







one more question with this i can get name but not displaying mobile number. alert("contacts:-->"+ JSON.stringify(contact.phoneNumbers)); this is working ,but <ion-input type="tel" [(ngModel)]="contact.mobile" name="mobile"></ion-input> out put"object object"

– user9088454
Nov 29 '18 at 7:17















I think mobile number input not accepting value, try change input type or remove input type.

– Khurshid Ansari
Nov 29 '18 at 8:25





I think mobile number input not accepting value, try change input type or remove input type.

– Khurshid Ansari
Nov 29 '18 at 8:25













this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

– user9088454
Nov 29 '18 at 9:30







this.contacts.pickContact().then((selectedContact)=>{ alert("contacts:-->"+ JSON.stringify(selectedContact.phoneNumbers)); //this.contact.name = selectedContact.displayName; this.contact.mobile = selectedContact.phoneNumbers; //this.contact.bday = selectedContact.birthday; }); like this single field working but when i am tring to get more then one ..problem there

– user9088454
Nov 29 '18 at 9:30






1




1





check my answer. you are not able to assign value properly.

– Khurshid Ansari
Nov 29 '18 at 10:48





check my answer. you are not able to assign value properly.

– Khurshid Ansari
Nov 29 '18 at 10:48




1




1





now everything working perfect...thanks boss

– user9088454
Nov 29 '18 at 11:35





now everything working perfect...thanks boss

– user9088454
Nov 29 '18 at 11:35




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519328%2fhow-to-display-selected-contact-using-pickcontact-ionic-v3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)