File

core/common/if-allowed.directive.ts

Description

A structural directive that conditionally includes a template only if the user has all or any of the roles passed as an input. By default the directive checks all roles:

 * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']" (click)="delete()" title="Delete">
 *   Delete
 * </button>
 *

To check if the user has any of the required roles to view the element you need to use the allowAny input:

 * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']; allowAny: true" (click)="delete()" title="Delete">
 *   Delete
 * </button>
 *

or use the shorter version

 * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']; allowAny" (click)="delete()" title="Delete">
 *   Delete
 * </button>
 *

Metadata

Selector [c8yIfAllowed]

Index

Methods
Inputs
Accessors

Constructor

constructor(template: TemplateRef, container: ViewContainerRef, permissions: Permissions)
Parameters :
Name Type Optional
template TemplateRef<any> No
container ViewContainerRef No
permissions Permissions No

Inputs

c8yIfAllowed

One or many roles required for the element to be rendered

c8yIfAllowedAllowAny

Switches to the mode where at least one of the provided roles is sufficient for the element to be rendered

Type : boolean

Methods

ngOnInit
ngOnInit()
Returns : void

Accessors

c8yIfAllowed
setc8yIfAllowed(roleIds)

One or many roles required for the element to be rendered

Parameters :
Name Optional
roleIds No
Returns : void
c8yIfAllowedAllowAny
setc8yIfAllowedAllowAny(allowAny: boolean)

Switches to the mode where at least one of the provided roles is sufficient for the element to be rendered

Parameters :
Name Type Optional
allowAny boolean No
Returns : void

result-matching ""

    No results matching ""