0

this is html code

i want to enable and disable input field depends on boolean value.but its not working.

     <md-checkbox (change)="triggerSomeEvent()"  [checked]="d.checked" [(ngModel)]="d.checked" formControlName="checked" >{{d.day}}</md-checkbox>

     <input  type="time" class="custome-text-input" [(ngModel)]="d.hoursofoperationto" formControlName="hoursofoperationto" [required]="days[i].checked" [disabled]="isDisabled">

This is component method

isDisabled = true;
    triggerSomeEvent(): void {
    this.isDisabled = !this.isDisabled;
}
sumit maske
  • 373
  • 4
  • 7
  • 15
  • https://stackoverflow.com/questions/49305257/attr-disabled-null-or-empty-string-is-returning-true – Eliseo Jun 26 '18 at 11:26
  • Code seems working fine see here https://stackblitz.com/edit/angular-tm77nn?file=src%2Fapp%2Fapp.component.html – Pardeep Jain Jun 26 '18 at 11:26
  • but its not working in my case. its giving following warning: It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this approach to avoid 'changed after checked' errors. Example: form = new FormGroup({ first: new FormControl({value: 'Nancy', disabled: true}, Validators.required), ast: new FormControl('Drew', Validators.required)}); – sumit maske Jun 26 '18 at 11:43

0 Answers0