Mat Stepper的代码
<mat-horizontal-stepper [linear]="isLinear" #stepper>
<mat-step [stepControl]="firstFormGroup" >
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Driver Details</ng-template>
<mat-form-field class="form-field-full-width">
<input [(ngModel)]="driverName" matInput placeholder="Name" formControlName="firstCtrl" required>
</mat-form-field><br>
<mat-form-field class="form-field-full-width">
<input [(ngModel)]="driverEmail" matInput placeholder="Email" formControlName="firstCtrl" required>
</mat-form-field><br>
...
</form>
</mat-step>
<mat-step [stepControl]="secondFormGroup">
<form [formGroup]="secondFormGroup">
.....
</form>
</mat-step>
</mat-horizontal-stepper>
这就是我将值设置为输入的方式
ngAfterViewInit(){
this.route.queryParams.subscribe(params => {
var driverDetails;
driverDetails = JSON.parse(params['driver']);
this.driverName = driverDetails['name'];
this.driverEmail = driverDetails['email'];
...
this.cdRef.detectChanges();
});
重新加载页面后,所有输入的值均为 driverName 。我该如何解决?
答案 0 :(得分:0)
发现错误。我已经使用了相同的formControlName进行外翻输入。