单击控制台中的“编辑”按钮后,我会得到字段列表,但这些值未绑定到字段中。 任何帮助表示赞赏。
HTML:
<div class="col-sm-3">
<label>SourceType</label>
<input type='text' (keyup)="searchDropDown(11, src.value)" #src formControlName="SourceType" [(ngModel)]="selectedText"/>
<div *ngIf="allergyDropDown && allergyDropDown?.sourceTypes">
<ul *ngFor="let sType of allergyDropDown?.sourceTypes" (click)="getValue(sType)" [hidden]="IsHidden">
<li >
{{sType.Description}}
</li>
</ul>
</div>
</div>
TS:
selectedText: '';
IsHidden:boolean = false;
public searchDropDown(Id, desc) {
this.IsHidden= !this.IsHidden;
let params = { Id, desc: desc }
this.emrService.getDropDown(params)
.subscribe((res) => {
console.log(res.Body.Data);
this.initializeAllDropDown(res.Body.Data)
})
}
public initializeAllDropDown(data) {
console.log(data);
this.allergyDropDown = <AllergyDropDown>{
sourceTypes: data ? data.filter(r => r.CategoryId == '11') : [],
};
}
getValue(item) {
this.IsHidden= !this.IsHidden;
if(item.CategoryId == 11) {
this.selectedText = item.Description;
}
}
单击编辑按钮,我将获得控制台值,功能如下:
public editAllergy(data, mode) {
console.log(data, mode);
this.selectedAllergy = { data, mode };
this.isShowAllergyDetails = true;
}