Angular 数据未显示在下拉模板驱动表单中
有一个模板驱动的表单,在该表单中有一个下拉列表。我想显示从后端到下拉列表的数据 这里的数据来自Angular 数据未显示在下拉模板驱动表单中,angular,angular-template-form,Angular,Angular Template Form,有一个模板驱动的表单,在该表单中有一个下拉列表。我想显示从后端到下拉列表的数据 这里的数据来自appliesweenda中的后端 <form #appliesWhen="ngForm"> <section class="form-inline" *ngFor="let awhen of appliesWhenData; let i = index;"> <div clas
appliesweenda
中的后端
<form #appliesWhen="ngForm">
<section class="form-inline" *ngFor="let awhen of appliesWhenData; let i = index;">
<div class="col-auto my-1">
<select class="custom-select mr-sm-2 form-control">
<option [ngValue]="" disabled >Select field</option>
<option [ngValue]="f" *ngFor="let f of fieldList">{{f.displayName}}
</option>
</select>
</div>
</section>
</form>
到目前为止,我所尝试的:
<form #appliesWhen="ngForm">
<section class="form-inline" *ngFor="let awhen of appliesWhenData; let i = index;">
<div class="col-auto my-1">
<select class="custom-select mr-sm-2 form-control" [(ngModel)]="awhen.fieldListDetail" name="fieldName{{ awhen.id }}">
<option [ngValue]="" disabled >Select field</option>
<option [ngValue]="f" *ngFor="let f of fieldList">{{f.displayName}}
</option>
</select>
</div>
</section>
</form>
选择字段
{{f.displayName}}
只有我需要在下拉列表中显示所选数据。来自后端的所选数据位于applieswernda.fieldlistdail
中,将出现的列表为fieldList
。
请帮忙
请尝试以下方式绑定数据:
{{f.fieldListDetail.displayName}
您正在使用*ngFor=“let f of fieldList”。fieldList中有什么类型的数据。您能告诉我们从该响应中需要使用哪些选项和值吗?@RK001实际上是一个下拉列表,用户可以更新数据。首先,当数据且列表位于字段列表中时,它将显示应用程序中的选定数据。@sankasanjeewa抱歉没有收到您的问题。@sandepkumar应该*ngFor=“let f of fieldList”
它应该是*ngFor=“let f of fieldList detail”
根据您打印的日志以及fieldListDetail上的更多内容,我想应该是一种数组类型
<form #appliesWhen="ngForm">
<section class="form-inline" *ngFor="let awhen of appliesWhenData; let i = index;">
<div class="col-auto my-1">
<select class="custom-select mr-sm-2 form-control" [(ngModel)]="awhen.fieldListDetail" name="fieldName{{ awhen.id }}">
<option [ngValue]="" disabled >Select field</option>
<option [ngValue]="f" *ngFor="let f of fieldList">{{f.displayName}}
</option>
</select>
</div>
</section>
</form>
<option [ngValue]="f" *ngFor="let f of fieldList">{{f.fieldListDetail.displayName}}
</option>