Since I donβt know how you manipulate activeCategory (maybe this is also FormControl ?), I suggest the following approach:
You can use (change) to detect when this.activeCategory has changed, as shown below:
1 - If you are using ngModel :
<input type="text" [(ngModel)]="activeCategory" (change)="checkValue($event)">
2 - If it is a FormControl :
<input type="text" formControlName="activeCategory" (change)="checkValue($event)">
So, in the component, you can control the docType control using the disable/enable methods:
checkValue(event: Event) { const ctrl = this.activityForm.get('docType'); if (event.value === 'document') { ctrl.enable(); } else { ctrl.disable(); } }
developer033
source share