-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
angular-structural-directive not working as explained in medium article #1033
Hi Team, I didn't find this one functional? do we have to write code in it? or am I missing something?
All reactions
Replies: 1 comment 4 replies
What do you mean ? Can you explain what it's not working for you ?
All reactions
I have been trying to run this in github codespaces but when I click on Admin or any role it doesn't do anything. It shows same page as we can see in information.component.ts there is nothing mentioned on the div, how will it filter than based on role.
Can't find code as well as mentioned in medium blog -
https://medium.com/@thomas.laforge/create-a-custom-structural-directive-to-manage-permissions-like-a-pro-11a1acad30ad
in 6-structural-directive there is no directive file as mentioned in the above blog. Please help.
All reactions
You can't run a closed PR in GitHub codespaces.
All reactions
Okay. Let me try at local environment. But I could not find the code mentioned in medium blog as well. Could you please help me?
All reactions
@jatingandhi28 The article doesn't explain everything and you have fill in some gaps.
First, you need to cd into the 6-structural-directive folder's app folder and use npx nx g directive hasRole. It will ask you what schematic to use either option should work. I went with nx schematic and the second choice on the second prompt.
The imports don't come up in VS Code when you copy and paste solution 1 into the new directive file.
This is the necessary import:
import {injectDestroyService, provideDestroyService} from "../../../libs/shared/utils/src/lib/destroy-service.service"
Then you need to add the code for isAdmin$ and hasAnyRole from user.store.ts in this PR .
Then you need add the hasRole directives to the template, etc.