I am trying to apply custom directive based on some condition in angular reactive form.But I have not find any way to implement this feature. Structural directive is not working in node projection.
<input
type="text"
*customDirective="data"
// directive1 /directive2
// I have to apply above directive based on some condition
/>
Try this:
@Directive({
selector: '[customRequired]'
})
export class CustomRequired {
@Input() customRequired: boolean;
@HostListener('change', ['$event'])
onCall(event) {
if(this.customRequired) {
// code to be done ....
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.