如何将值设置/修补到ngx-mat-select-search drop .ngx-mat-select-search以动态形式(表单数组)使用,因此表单控件名称类似于所有动态创建的下拉列表。如何为更新。
setCPT(cpt){
const formArray = new FormArray([]);
if (cpt.length>0){
cpt.forEach(element => {
this.selectedCpt(element.cpt.cpt_code)
var selectedCptVal = [];
selectedCptVal.push(element.cpt.cpt_code)
this.filteredBanks.next(selectedCptVal.slice());
this.cpt=selectedCptVal[0];
console.log(element)
formArray.push(this._fb.group({
cpt:element.cpt.cpt_code,
mac_locality:element.cpt.id,
fee_schedule:element.fee_schedule,
id:element.id
}))
});
}
return formArray;
}
<form [formGroup]="cptForm">
<div class="row" formArrayName="cpt">
<div class="col-12" *ngFor="let group of cptArray.controls; let i = index;" [formGroupName]="i">
<div class="form-group row">
<label class="col-sm-4 col-form-label">CPT Code</label>
<div class="col-sm-8">
<div class="form-group">
<!-- <mat-select class="form-control mb-1" required [formControl]="bankCtrl" name="bankCtrl" placeholder="CPT Code" #singleSelect> -->
<mat-select class="form-control mb-1" ngDefaultControl required (selectionChange)="selectedCpt($event.value)" [formControl]="cpt" name="cpt" placeholder="CPT Code" #singleSelect>
<ngx-mat-select-search [formControl]="bankFilterCtrl" [placeholderLabel]="'Search Cpt Code'" [noEntriesFoundLabel]="'No matching records found'"></ngx-mat-select-search>
<mat-option disabled> Cpt Code </mat-option>
<mat-option *ngFor="let bank of filteredBanks | async" [value]="bank">
{{bank}}
</mat-option>
</mat-select>
</div>
</div>
</div>
</div>
<div>
</form>
答案 0 :(得分:0)
您可以使用localhost/hello-world?lang=en
方法
setValue