question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage question - ngxPermission directive

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ranjithsiamcommented, Aug 6, 2018

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.

0reactions
AlexKhymenkocommented, Sep 24, 2018

@architechcro Do You still need help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngx-permissions error with directive *ngxPermissionsOnly
I have a problem with the directive of the library ngx-permissions. These are the versions of my angular's dependency:
Read more >
Extend the *ngIf Syntax to Create a Custom Permission Directive
So our use case is to create a directive, which shows/hides elements on the page based on our currently authenticated user's permissions.
Read more >
Dealing With Permissions in Angular and NgRx
Angular directives are a specific decorator you can attach to any element in the DOM to apply custom behaviors, such as custom CSS,...
Read more >
Angular - How to check authorization based on role and entity ...
... with role-base authorization will save you for this problem. ... so is better to use structural directives (Thanks to my colleague Petyo ......
Read more >
Bountysource
Usage question - ngxPermission directive. ... Help and Information. Frequently Asked Questions · Bugs and Feature Requests · Fees ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found