How to disable reactive toggle?


#1

There are older posts on this topic, but there is a new wrinkle on it. As discussed extensively on the Web, and in this resolved issue https://github.com/angular/angular/issues/11271 , we’re not supposed to use disabled=“true” as shown in the documentation for ion-toggle when it is a form control. So I disabled the form control in the recommended way, fc.myToggle.disable(). This sets the formControl.disabled flag to true, but it doesn’t disable the ion-toggle. So is there a way to disable the ion-toggle without triggering the ugly warning? This is the ugly warning that shows up in the console:

  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),
    last: new FormControl('Drew', Validators.required)
  });

#2

I am also curious about this. I am wondering, what is the benefit of even disabling the angular FormControl when you have disabled the UI element using Ionic? But to your point, I would also really like a way to prevent the nasty warning messages that get sprayed all over the console when using [disabled]


#3

Any news in this? I have the same issue…


#4

Seems there’s already an issue for that: https://github.com/driftyco/ionic/issues/9041