Код: Выделить всё
Content 1
Content 2
Content 3
hidden
visible
< /code>
HideMeКод: Выделить всё
@Directive({
selector: '[appHideMe]'
})
export class HideMeDirective implements AfterViewInit {
constructor(
private el: ElementRef
) { }
ngAfterViewInit() {
this.el.nativeElement.style.display = 'none';
}
}
< /code>
As during compilation, mat-tabВот пример Stackblitz.
Я также хочу, чтобы Mat-tab < /code> был включен. В этом примере я ожидаю, что третий будет видимым, но это не так.
шаблон
Код: Выделить всё
Content 1
Content 2
Content 3
Content 4
hidden
visible
< /code>
directive code
@Directive({
selector: '[appHideMe]'
})
export class HideMeDirective implements AfterViewInit {
@Input() appHideMe: string;
constructor(
private el: ElementRef
) { }
ngAfterViewInit() {
if (this.appHideMe === 'hide') {
this.el.nativeElement.style.display = 'none';
}
// should be displayed
// this.el.nativeElement.style.display = 'none';
}
}
< /code>
As long as there is no HideMeDirectiveПодробнее здесь: https://stackoverflow.com/questions/518 ... -directive
Мобильная версия