I have two arrays like
var members = [{docId: \"1234\", userId: 222}, {docId: \"1235\", userId: 333}];
var memberInfo = [{id: 222, name: \"test1\"}, {id: 333
You can achieve using foreach function
and creating the third array and displaying it.
$scope.members = [{docId: "1234", userId: 222}, {docId: "1235", userId: 333}];
$scope.memberInfo = [{id: 222, name: "test1"}, {id: 333, name: "test2"}];
$scope.finalArray = [];
angular.forEach($scope.members, function(member) {
angular.forEach($scope.memberInfo, function(memberInfo) {
if(member.userId ==memberInfo.id) {
var test = {
docId : member.docId,
userId: member.userId,
name: memberInfo.name
}
$scope.finalArray.push(test);
}
});
});
Here is the working plunker:
http://embed.plnkr.co/QRB5v2cI6SZOdZgdqDVR/preview
Hope it helps!