import { Directive, Input, ElementRef, OnInit } from '@angular/core'; import { ProfileService } from '../../services/profile.service'; @Directive({ selector: '[appMultiplePrivilege]' }) export class MultiplePrivilegeDirective implements OnInit { @Input() checkPrivilegeOne: string; @Input() checkPrivilegeTwo: string; constructor(private el: ElementRef, private profileService: ProfileService) {} ngOnInit() { if ( this.profileService.privileges.findIndex( x => x === this.checkPrivilegeOne ) <= -1 && this.profileService.privileges.findIndex( x => x === this.checkPrivilegeTwo ) <= -1 ) { this.el.nativeElement.style.display = 'none'; } } }