Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*ngFor #4

Closed
guygit opened this issue Sep 14, 2017 · 1 comment
Closed

*ngFor #4

guygit opened this issue Sep 14, 2017 · 1 comment
Assignees
Labels

Comments

@guygit
Copy link

guygit commented Sep 14, 2017

Hi,

it seems, the directives (eg. ngxPermissionsOnly) cannot be used within an "*ngFor" loop.

Example:
...*ngFor="let child of children" ..

{{child.value}}

In the example above, {{child.value}} does not get rendered - it seems to be shadowed by your Directive.

Can you confirm?
Is it by intent?

Thx a lot,

raven

@AlexKhymenko
Copy link
Owner

AlexKhymenko commented Sep 14, 2017

Cause github messed up a lttle bit your question. If You use The latest version of library if you don't pass any value it will render the element. The second part is before i understood that the mark up is messed up :-)

Hi it depends on your intention. But the main restriction it can't be used in the same line as *ngFor(Angular restriction not the library like you can't use ngIf with ngFor)

 <div *ngFor="let elem of elements" *ngxPermissionsOnly="Guest">
     this will not work
  </div>
 </div>

and if you have permissions in children you can use it like this

<div *ngFor="let item of group.children">
        <ng-container *ngxPermissionsOnly="item.permission">
          <a
             [routerLink]="[item.url]"
             (click)="toggleOpen()"
             routerLinkActive="active"
             [ngClass]="{'active': item.isActive}"
             class="menu-item">
            <span translate>{{item.title}}</span>
          </a>
        </ng-container>
      </div>

and the 3 when you dont what to show ngFor at all You write like this

      <ng-container *ngxPermissionsOnly="Admin">
         <div *ngFor="let item of group.children" ngClass="{'separator': item.separator}" >
         </div> 
      <ng-container>

Hope This helps. Have A Nice Day!!

@AlexKhymenko AlexKhymenko self-assigned this Sep 14, 2017
yd021976 pushed a commit to yd021976/ngx-permissions that referenced this issue Nov 7, 2018
AlexKhymenko added a commit that referenced this issue Jun 10, 2019
* upgrade to Angular 7

* Enhance custom strategy callback with permissions states
Enhance event emmiter "authorised" and "unAuthorised" with permissions states

* Tests configuration

* Tests spec rewrite

* configure and update tests spec

* Complete run tests of library

* code cleaning & improve comments and readability

* Correct syntax "sholud" by "should" in tests spec files

* Add code coverage report

* Try to solve Travis CI build failed #1

* Try to solve Travis CI build failed #2

* Try to solve Travis CI build failed #3

* Try to solve Travis CI build failed #4

* Try to solve Travis CI build failed #5

* PR#89 : Add 11 new spec test for permissions.directive.ts

* Working on ivy

* Make ivy available

* Make normal structure

* Fix testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants