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

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

Here is my component in Angular 4:

@Component( {
    selector: \'input-extra-field\',
    template: `
            
20条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 15:58

    This is kind of stupid, but I got this error message by accidentally using [formControl] instead of [formGroup]. See here:

    WRONG

    @Component({
      selector: 'app-application-purpose',
      template: `
        
    ` }) export class MyComponent implements OnInit { formGroup: FormGroup constructor( private formBuilder: FormBuilder ) { } ngOnInit() { this.formGroup = this.formBuilder.group({ formGroupProperty: '' }) } }

    RIGHT

    @Component({
      selector: 'app-application-purpose',
      template: `
        
    ` }) export class MyComponent implements OnInit { formGroup: FormGroup constructor( private formBuilder: FormBuilder ) { } ngOnInit() { this.formGroup = this.formBuilder.group({ formGroupProperty: '' }) } }

提交回复
热议问题