I have a function that checks for userPermissions and it is part of a Service called MyService . I am passing in an array with only one string. The issue I am facing is angular.forEach is looping through character by character instead of the complete string. Please can you advise?
//Service changes
MyService.userHasPermission("['Read']")
//Permission function
function userHasPermission (permissions){
var found = false;
angular.forEach(permissions, function(expectedPermission, index){
if ($localStorage.userPermissions.indexOf(expectedPermission) >= 0){
found = true;
return;
}
});
return found;
};
MyService.userHasPermission(['Read'])