是否有人成功使用mat-selection-list
与Angular的反应形式。
当我尝试使用它时,我正在
values.map不是函数
下面是我的HTML代码:
<div class="form-group" [formGroup]="activityForm">
<mat-selection-list formControlName="activity" (selectionChange)="onActivitySelected($event)">
<mat-list-option *ngFor="let act of activities"
[value]="act.id">
{{act.name}}
</mat-list-option>
</mat-selection-list>
</div>
这是我的表单定义:
this.formGroup1 = this.fb.group({
destinationForm: this.fb.group({
destination: [null, Validators.required]
}),
activityForm: this.fb.group({
activity: [[''], Validators.required]
}),
travellerForm: this.fb.group({
firstName: ['', Validators.required],
lastName: '',
})
});
请有人帮忙解决这个问题
答案 0 :(得分:2)
this.formGroup1 = this.fb.group({
destinationForm: this.fb.group({
destination: [{value: null, disabled: false}, [Validators.required]]
}),
activityForm: this.fb.group({
activity: [{value: '', disabled: false}, [Validators.required]]
}),
travellerForm: this.fb.group({
firstName: [{value: '', disabled: false}, [Validators.required]]
lastName: [{value: '', disabled: false}]
})
});