Usage question - ngxPermission directive
See original GitHub issueI’m submitting a
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ x ] Documentation issue or request
Current behavior
ngxPermissionOnly directive syntax is not working as described in documentation. I’ve tested several syntax cases and only one that works throws typescript error tested:
1. <div *ngxPermissionsOnly="['GUEST']">GUEST</div>
2. <div *ngxPermissionsOnly="GUEST">GUEST - 2</div>
3. <div *ngxPermissionsOnly="'GUEST'">GUEST - 3</div>
4. <div *ngxPermissionsOnly="['GUEST']">GUEST - 4</div>
5. <div *ngxPermissionsOnly="['ADMIN']">ADMIN</div>
6. <div *ngxPermissionsOnly="['USER']">USER</div>
7. <div *ngxPermissionsOnly="'GUEST', 'ADMIN'">GUEST, ADMIN - 3</div>
Only GUEST-2 ( example 2. ) is displayed, but there is a build error: [Angular] Identifier ‘GUEST’ is not defined. The component declaration, template variable declarations, and element references do not contain such a member
I’ve tried several more syntax combinations and only permissions without ‘’ work. e.g. *ngxPermissionsOnly=“GUEST” *ngxPermissionsOnly=“[ADMIN, GUEST]”
Expected behavior
Examples 1., 3., 4., 5., 6., 7. should work ( depending on the active roles )
Minimal reproduction of the problem with instructions
Installation done as described. Roles assigned
rolesService.addRole(element.roleName, element.permissions);
Roles service returns assigned roles as expected
this.rolesService.roles$.subscribe( res => {
this.roles = res;
});
Environment
Angular version: 6.0.1
ngx-permissions version: 5.0.0
Browser:
- [x ] Chrome (desktop) version 67.0.3396.99 (Official Build) (64-bit)
- [ x] Chrome (Android) version 68.0.3440.85
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
I’m also having the same issue. My angular version is 6.0.0 and ngx-permission version is 5.0.0. Checked with all the syntax and its not working. Kindly help with this issue.
@architechcro Do You still need help?