这些是我的文件。我收到此错误有人可以帮助我。
Error: src/app/app.component.html:5:123 - error TS4111: Property 'fName' comes from an index signature, so it must be accessed with ['fName'].
<input id="name" type="text" formControlName="fName" class="form-control" [ngClass]="{'is-invalid':submitted && f.fName.errors}"/>
Run Code Online (Sandbox Code Playgroud)
组件.html
<form [formGroup]="surveyForm" (ngSubmit)="onSubmit()">
<div>
<label>Name:</label>
<input id="name" type="text" formControlName="fName" class="form-control" [ngClass]="{'is-invalid':submitted && f.fName.errors}"/>
<div *ngIf="submitted && f.fName.errors" class="form-control">first name is required</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
组件.ts
import { Component, OnInit } from '@angular/core';
import { FormControl, FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements …Run Code Online (Sandbox Code Playgroud)