I have an array of user objects called allUsers and I need to check each object in it with the groupId which is passed to the function and return userNames which have the passed groupId.
I attempted this in the following manner.
vm.setNames=function(groupId){
var products = "";
angular.forEach(vm.allUsers,function (f) {
if(f.groupId==groupId){
vm.user=f;
users= users+','+" "+vm.user.userName;
}
})
return users= ;
}
I want to have it in a map with group id as the key and relevant user names as values and return the relevant user names. How can I do that?