In AngularJS controller, I am having the associative array called contact. I have to get the elements of the array which has no name. here I have posted my code and response for your reference
this is my controller code
function onSuccess(contacts) {
console.log(contacts);
for (var i = 0; i < contacts.length; i++) {
var list = contacts[i].phoneNumbers;
console.log(list);
}
}
this my contacts array
[Contact, Contact, Contact, Contact, Contact, Contact, Contact, Contact]
0:Contact
addresses:null
birthday:Invalid Date
categories:null
displayName:"UIDAI"
emails:null
id:"16"
ims:null
name:Object
nickname:null
note:null
organizations:null
phoneNumbers:Array[1]
0:Object
id:"109"
pref:false
type:"other"
value:"1800-300-1947"
__proto_:Object
length:1
__proto_:Array[0]
photos:null
rawId:"17"
urls:null
__proto__:Object
1:Contact
addresses:null
birthday:Invalid Date
categories:null
displayName:"Distress Number"
emails:null
id:"17"
ims: null
name:Object
nickname: null
note:null
organizations:null
phoneNumbers:Array[1]
0:Object
length:1
__proto__:Array[0]
photos:null
rawId :"16"
urls:null
__proto__:Object
this my log of console.log(list) array
Array[8]
0:Array[1]
0:Object
id:"109"
pref:false
type:"other"
value:"1800-300-1947"
In here I have to get the element value from this.
contacts[i].phoneNumbers.value?contacts[i].phoneNumbers[0].valueyou may test ifphoNumbersis defined and is not an empty array to return an empty string if so.