AlexKhymenko / ngx-permissions

Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
MIT License
936 stars 126 forks source link

ngx-permissions not working in child-components (features) #210

Closed atarazavi closed 1 year ago

atarazavi commented 1 year ago

When a child component with this html code: image

is being loaded, this error happens:

image

Importing NgxPermissionsModule.forRoot() in app.module is done! Importing NgxPermissionsModule.forChild(), in child components is done! Whether it's LazyLoading or not, it doesn't work for the components! BUT when I add *ngxPermissionsOnly="['ADMIN']" to app.component.html it works! So It's facing the problem just for child components! I tried many different ways and found a solution! Including the child components in declarations array in app.module! But I don't like this solution! And I think it is in contrast with the LazyLoading concept! Also using sharedModule didn't solve the problem!

Environment

Angular version: 14.2.X ngx-permissions version: 14.0.0

Browser:

senbagaraman04 commented 1 year ago

I work with angular 13.x and ngx-permission 13.x - it works by importingforchild() in the lazy loaded module. Can you share the minimal reproducible code in stack-blitz?