i am work on ionic contect to get the contact name & number but i get name And [object object] contact number not dispaly.
this my code .
.ts
constructor(…){
contacts.find([‘displayName’, ‘phoneNumbers’], { filter: “”, multiple: true })
.then(data => {
this.contactlist = data
alert(this.contactlist);
});
}
html
{{contact.displayName}}
{{ contact.phoneNumbers }}
any one worke on this module please share suggestion…?
You image show the variable is an object.
That means “contact.phoneNumbers” is object.
Just replace “alert(this.contactlist);” with “console.log(this.contactlist);” and u will know the data structure.
or
{{ contact.displayName | json}}
data show in json format and phoneNumber show in array…thaqu soo much @sonicwong …
hy @sonicwong
how to get the data in this array …
array data
{
“_objectinstance”: {
“id”:“452”,
“rawld”:“452”,
“displayName”:“police”,
“name”: {
“givenName”:“Police”,“formated”:“police”
},
“nickname”:null,
“phoneNumbers”:[{
“id”:“1493”,“perf”:false,“value”:“11110” ,“type”:“mobile”
}],
“emails”:null,
“addresses”:null,
“ims”:null,
“organizations”:null,
“birthday”:null,
“photos”:null,
“categories”:null,
“urls”:null
}
}
this is my files…
.ts
constructor(…){
this.contacts.find([‘displayName’, ‘phoneNumbers’], { filter: “”, multiple: true })
.then(data => {
this.contactlist = data;
});
}
html
{{contact.displayName}}
{{ contact.phoneNumbers}}
name show but i need phone number …? please check
saurabhsharma17:
11110
In my opinion, u should flatten the array to string in ts side.
or a dirty way… {{ contact.phoneNumbers[0].value }}