要素をレンダリングするかどうかを決定するディレクティブを実装しました。ViewContainerRefで作成された要素を無効にすることは可能ですか?
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
export class MyDirective {
constructor(private _templateRef: TemplateRef<any>,
private _viewContainer: ViewContainerRef) {
}
@Input() set method() {
this._viewContainer.clear();
if (// some logic here //) {
this._viewContainer.createEmbeddedView(this._templateRef) // render element
}
}
私の問題は、今私は要素をレンダリングしたいが、私はまた、それが有効かどうかを決定する必要があります。指令自体の中でこれを行う方法はありますか?
'cdk'が最善の方法が、実装するのは困難です。 –