Last active
May 12, 2021 08:53
-
-
Save fdonzello/46419db3dfde22a516295189da93254d to your computer and use it in GitHub Desktop.
Usage of the if-granted component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core'; | |
import {UserTypes} from '../../../models/models'; | |
@Component({ | |
selector: 'app-my-home', | |
template: ` | |
This is visible to Admin, User and Guest. | |
<app-if-granted [allowedRoles]="[userTypes.Admin, userTypes.User]"> | |
<!-- This is visible only to Admin and User --> | |
<button>Yes, I can!</button> | |
</app-if-granted> | |
`, | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class MyHomeComponent implements OnInit { | |
userTypes = UserTypes; | |
constructor() { | |
} | |
ngOnInit(): void { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment