File

packages/components/directives/eui-has-permission.directive.ts

Description

A structural directive that conditionally renders content based on user permissions. Similar to *ngIf, but checks against a permission service to determine visibility.

Example :
<!-- Single permission check -->
<div *euiHasPermission="['READ_USERS']">
  Content only visible to users with READ_USERS permission
</div>


<!-- Multiple permission check (AND operation) -->
<div *euiHasPermission="['READ_USERS', 'WRITE_USERS']">
  Content only visible to users with both permissions
</div>


<!-- Using OR operator -->
<div *euiHasPermission="['READ_USERS', 'WRITE_USERS']" operator='OR'">
    Content visible to users with either permission
</div>

The directive performs an AND operation when multiple permissions are provided, meaning all permissions must be granted for the content to be displayed.

Metadata

Index

Inputs
Accessors

Inputs

euiHasPermission
Type : any
euiHasPermissionOperator
Type : ConditionOperator

Sets the logical operator for permission checks. Can be 'AND' (default) or 'OR'.

  • 'AND': All permissions must be granted to display the content.
  • 'OR': At least one permission must be granted to display the content.

Accessors

euiHasPermissionOperator
seteuiHasPermissionOperator(operator: ConditionOperator)

Sets the logical operator for permission checks. Can be 'AND' (default) or 'OR'.

  • 'AND': All permissions must be granted to display the content.
  • 'OR': At least one permission must be granted to display the content.
Parameters :
Name Type Optional
operator ConditionOperator No
Returns : void
euiHasPermission
seteuiHasPermission(val: unknown)

Sets the permissions required to display the content. Can be a single permission string or an array of permission strings.

Parameters :
Name Type Optional Description
val unknown No
  • Permission or array of permissions to check
Returns : void

results matching ""

    No results matching ""