我使用本機用於獲取來自手機獲取聯繫人顯示名稱和PHONENUMBERS
.TS聯繫人列表中的聯繫人離子:
import { Contacts } from 'ionic-native';
/////////
export class ContactPage {
contactsfound = []
constructor(public navCtrl: NavController) {
Contacts.find(["displayName", "phoneNumbers"], {multiple: true}).then((contacts) => {
this.contactsfound = contacts;
})
}
}
的.html:
<ion-content>
<ion-list>
<ion-list-header>Follow us on Twitter</ion-list-header>
<ion-item *ngFor="let item of contactsfound">
{{ item.displayName }}
<p>{{ item.phoneNumbers }}</p>
</ion-item>
</ion-list>
</ion-content>
我收到清單displayName
正確但是爲phoneNumbers
我得到[object Object]
如何做到這一點? 此外,我想在列表的左側有一個字母,其中代表以該字母開頭的一組聯繫人的第一個字母(例如,列表組,然後滾動B列表組)。如果有人提供關於這方面的見解,那就太棒感謝名單
嘗試在控制檯中打印對象並進行調試:'console.log(JSON.stringify(contactsfound))'。 phoneNumbers屬性顯然是一個對象,而不是一個數字/字符串值 –
@suraj ...我不能在控制檯中打印,這個插件只適用於真正的設備...是的,它是一個對象,而displayName是字符串...它似乎'phoneNumbers'是所有聯繫人電話號碼的數組......所以如何訪問它們並相應地顯示它們 – Yasir
您仍然可以使用Chrome開發人員工具查看控制檯日誌.. https://developers.google.com/web/工具/ chrome-devtools/remote-debugging/ –