-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Question Angular template: Is there any function available to check if user has permission #2737
Comments
@thiag0coelho do you mean permissions ? |
Yes, there is such a feature. See its usage: https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html#L9 |
@mehmet-erim can you write for different use cases? |
@hikalkan That worked for hiding. Thanks! |
You can use the Attiribute usage: <button abpPermission="Type here a policy key e.g: AbpIdentity.Users.Create">Create a new user</button> Structural usage: <button *abpPermission="'Type here a policy key'">Create a new user</button>
You can also manage the permission of a route with import { PermissionGuard } from '@abp/ng.core';
// ...
{
path: 'your-route-path',
component: YourComponent
canActivate: [PermissionGuard],
data: {
routes: {
requiredPolicy: 'Type here a policy key',
},
},
} To disable a DOM elementAdd a select decorator to your component as shown below: import { ConfigState } from '@abp/ng.core';
import { Select } from '@ngxs/store';
// ...
export class YourComponent {
@Select(ConfigState.getGrantedPolicy('Type here a policy key'))
createButtonPermission$: Observable<boolean>
// ... Use <button [disabled]="!(createButtonPermission$ | async)">Create new</button> |
@mehmet-erim Is there a way to use OR/AND within *abpPermission? Thats because I have a "more actions" menu button that shows edit and delete buttons, and want to hide the menu button if cannot edit and delete |
@luisp88 You can use permission directive like this: *abpPermission="'YourModule.Edit || YourModule.Delete'"
or
*abpPermission="'YourModule.Edit && YourModule.Delete'" For further information, see the permission management documentation You can also get permissions manually via |
Angular template v2.0.1
I need to hide or disable components, I need something to check policies and act like so:
Is there any way to do this, using directive, service, something?
The text was updated successfully, but these errors were encountered: