0

我正在尝试根据某些条件以角度反应形式应用自定义指令。但我还没有找到任何方法来实现此功能。结构指令在节点投影中不起作用。

     <input
        type="text"
        *customDirective="data"
       // directive1 /directive2    
       // I have to apply above directive based on some condition      
         />
4

1 回答 1

1

尝试这个:

@Directive({
    selector: '[customRequired]'
})
export class CustomRequired {
    @Input() customRequired: boolean;

    @HostListener('change', ['$event'])
    onCall(event) {
        if(this.customRequired) {
        // code to be done ....
        }
    }
}
于 2019-02-20T08:19:07.190 回答