psi_mmobile

Untitled

Jun 18th, 2025
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import { Directive, TemplateRef, ViewContainerRef } from '@angular/core';
  2. import { zip } from 'rxjs';
  3. import { take } from 'rxjs/operators';
  4. import { HeaderService } from 'src/app/core/services/header.service';
  5.  
  6. @Directive({ selector: '[admin]' })
  7. export class AdminDirective {
  8. constructor(
  9. private templateRef: TemplateRef<any>,
  10. private viewContainer: ViewContainerRef,
  11. private headerService: HeaderService
  12. ) {
  13. this.headerService.modulesURL[MODULE_ID].access
  14. .asObservable()
  15. .subscribe(({ readOnly }) => {
  16. this.readOnly = readOnly;
  17. if (this.readOnly)
  18. ) {
  19. this.viewContainer.createEmbeddedView(this.templateRef);
  20. } else {
  21. this.viewContainer.clear();
  22. }
  23. })
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment