[英]How can we apply custom directive conditionally in angular 6 when using node projection with <ng-container></ng-container>?
我正在嘗試根據角度反作用形式的某些條件應用自定義指令。但是我找不到任何實現此功能的方法。 結構指令在節點投影中不起作用。
<input
type="text"
*customDirective="data"
// directive1 /directive2
// I have to apply above directive based on some condition
/>
嘗試這個:
@Directive({
selector: '[customRequired]'
})
export class CustomRequired {
@Input() customRequired: boolean;
@HostListener('change', ['$event'])
onCall(event) {
if(this.customRequired) {
// code to be done ....
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.