How to initializate a mat-slide-toggle of Material Design in Angular 5?

后端 未结 1 1217
日久生厌
日久生厌 2021-01-12 07:47

I can\'t make the initialization of a mat-slide-toggle in a Reactive Form.

I have something like in the template



        
1条回答
  •  执念已碎
    2021-01-12 08:51

    IMHO, there's some issue with your code. You should do something like this:

    {{X.value ? 'ON' : 'OFF'}}              
    

    And in controller you'll need to assign the formControl so, use = instead of : ie:

     X = new FormControl(true, [
          Validators.required
     ]);
    

    0 讨论(0)
提交回复
热议问题