🚨 Announcing Vendure v2 Beta

IfPermissionsDirective

IfPermissionsDirective

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

Example

<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)

Signature

class IfPermissionsDirective extends IfDirectiveBase<Array<Permission[] | null>> {
  constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<any>, dataService: DataService, changeDetectorRef: ChangeDetectorRef)
}

Extends

Members

constructor

method
type:
(_viewContainer: ViewContainerRef, templateRef: TemplateRef<any>, dataService: DataService, changeDetectorRef: ChangeDetectorRef) => IfPermissionsDirective