如何提供用户角色NGX的权限在角2/4
问题描述:
我想实现的文章#1中https://stackoverflow.com/a/45866966/8601771提到NGX的权限,但我不知道该怎么落实如何提供用户角色NGX的权限在角2/4
(permissionsAuthorized )= “yourCustomAuthorizedFunction()”
(permissionsUnauthorized)=“yourCustomAuthorizedFunction()是这个强制性的。如何在用户角色获得通过的标签?
<div>You can see this text congrats</div>
</ng-template>
<div *ngxPermissionsOnly="['ADMIN', 'GUEST']">
<div>You can see this text congrats</div>
</div>
<div *ngxPermissionsExcept="['ADMIN', 'JOHNY']">
<div>All will see it except admin and Johny</div>
</div>
在上述代码中,用户登录凭证的设置在哪里?
答
“permissionsAuthorized”只是当元素显示时将被调用的事件。例如,如果您不需要它,但您不需要实现它,则需要在用户拥有权限时显示消息。管理员,访客是用户角色。
有关文件,请访问ngx-permissions wiki。
要加载的作用,你应该写
constructor(private ngxRolesService: NgxRolesService) {}
addRole() {
this.ngxRolesService.addRole('Guest',() => {
return true
});
}