Back to Vendure

IfPermissionsDirective

docs/docs/reference/admin-ui-api/directives/if-permissions-directive.mdx

3.7.11.0 KB
Original Source
<GenerationInfo sourceFile="packages/admin-ui/src/lib/core/src/shared/directives/if-permissions.directive.ts" sourceLine="26" packageName="@vendure/admin-ui" />

Conditionally shows/hides templates based on the current active user having the specified permission. Based on the ngIf source. Also support "else" templates:

Example

html
<button *vdrIfPermissions="'DeleteCatalog'; else unauthorized">Delete Product</button>
<ng-template #unauthorized>Not allowed!</ng-template>

The permission can be a single string, or an array. If an array is passed, then all of the permissions must match (logical AND)

ts
class IfPermissionsDirective extends IfDirectiveBase<Array<Permission[] | null>> {
    constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<any>, changeDetectorRef: ChangeDetectorRef, permissionsService: PermissionsService)
}
  • Extends: IfDirectiveBase<Array<Permission[] | null>>
<div className="members-wrapper"> </div>