我有 angular2 反应形式,其中包含 md-select 以使用户从 firebase 中选择医生 md-select 在呈现组件之前存在数据时可以正常工作,但是如果数据以可观察的方式异步传入,则它不会显示所选值
doctors$:Observable< Doctor[] > = this.doctorService.findAllDoctors();
constructor(private fb:FormBuilder , public doctorService : DoctorService
,private cdr: ChangeDetectorRef )
{
this.doctors$= this.doctorService.findAllDoctors();
this.form = this.fb.group({
FullName: ['',Validators.required],
Ext: [''],
BirthDate: ['',Validators.required],
Gender: ['',Validators.required],
Phone: ['',[Validators.required]],
doctorId: ['']
});
<md-select formControlName="doctorId" ngControl="doctorId" placeholder="Doctor" >
<md-option *ngFor="let p of doctors$ | async " [value]="p.value">{{p.value}}</md-option>
</md-select>
在这里输入代码