Reputation: 1586
I get following array from a service (roles of a logged in user) roles = ['MM_VIEW', EM_VIEW]
I have a requirement where I need to check whether the user have any one of the below roles and based on that I need to do some logic MM_VIEW, MM_EDIT, MM_DELETE
So, I was wondering how to proceed with this, to create a enum or directly use OR condition like below
if (user.roles.includes('MM_VIEW') || user.roles.includes('MM_EDIT') || user.roles.includes('MM_DELETE')) {
this.appImgPIIError.emit(true);
} else {
this.appImgPIIError.emit(false);
}
This works, but somehow having hard coded values in my component is not seems a good idea to me. ANy suggestions are welcome. Thanks.
Upvotes: 0
Views: 468