ERROR Error: No value accessor for form control with unspecified name attribute on switch

后端 未结 20 2401
感情败类
感情败类 2020-12-07 15:33

Here is my component in Angular 4:

@Component( {
    selector: \'input-extra-field\',
    template: `
            
相关标签:
20条回答
  • 2020-12-07 16:10

    In my case, the error was triggered by duplicating an import of a component in the module.

    0 讨论(0)
  • 2020-12-07 16:12

    I was getting this error message in my Unit tests with Jasmine. I added ngDefaultControl attribute to the custom element(in my case it was an angular material slide toggle) and this resolves the error.

    <mat-slide-toggle formControlName="extraCheese">
      Extra Cheese
    </mat-slide-toggle>
    

    Change the above element to include ngDefaultControl atttribute

    <mat-slide-toggle ngDefaultControl formControlName="extraCheese">
     Extra Cheese
    </mat-slide-toggle>
    
    0 讨论(0)
提交回复
热议问题