Angular之ngx-permissions的角色管理
案例 demo https://stackblitz.com/edit/ngx-permissions-role
介紹
通過定義一個角色是一組指定的由特定用戶組的鑒別能力(權限)。因此,例如用戶或匿名的角色和權限不夠。我們可以代表我們作為一組權限的角色應該是能夠執行的用戶角色。
定義角色
單個角色
通過NgxRolesService
的addRole
方法自定義角色在你的app內。
首先導入NgxRolesService
服務:
import { NgxRolesService } from 'ngx-permissions';
然后需要在構造函數中導入。
constructor(private