I'm encountering an issue with retrieving values from an angular forEach loop.
Below is the data I am working with:
vm.memberDetails={
"member": [
{
"firstName": "HARRY UTTWO",
"lastName": "POTTER",
}
],
"User": [
{
"memberId": 7586671,
"customerId": 7586671,
"customerStatus": "T",
"firstName": "HEMOOINE",
"lastName": "POTTER",
},
]
}
vm.mockData = {
"data": [{
"memberNo": 7586671,
"suffix": "A"
}]
}
The challenge I am facing involves comparing memberId and retrieving the name from the first set of data. I attempted to use angular.forEach but only managed to retrieve one value during looping using
vm.memberDetails.User[0].firstName
.
Controller:
angular.forEach(vm.memberDetails.User, function (value1,key1) {
angular.forEach(vm.mockData, function (value2,key2) {
if (value1.memberId === value2.memberNo) {
vm.some= vm.memberDetails.User[0].firstName;
}
});
});
return vm.some;
Any assistance on this matter would be highly appreciated. Thank you.