Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Directive, TemplateRef, ViewContainerRef } from '@angular/core';
- import { zip } from 'rxjs';
- import { take } from 'rxjs/operators';
- import { HeaderService } from 'src/app/core/services/header.service';
- @Directive({ selector: '[admin]' })
- export class AdminDirective {
- constructor(
- private templateRef: TemplateRef<any>,
- private viewContainer: ViewContainerRef,
- private headerService: HeaderService
- ) {
- this.headerService.modulesURL[MODULE_ID].access
- .asObservable()
- .subscribe(({ readOnly }) => {
- this.readOnly = readOnly;
- if (this.readOnly)
- ) {
- this.viewContainer.createEmbeddedView(this.templateRef);
- } else {
- this.viewContainer.clear();
- }
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment