UI包含单选按钮YES和NO和下拉列表,我已经为单选按钮创建了后端API服务,其中我动态发送YES和NO params值与URL(GET),如果用户发送YES作为响应我得到列表客户端,现在基于YES参数值,如何在下拉选项中显示(清单)angular 2 typescript。
URL : http://localhost:9095/api/v1/client/list?isyourClient={Y}
Sample Response :
[{ "userId": "Mind.com","clientCode": "25","clientName": "CORPORATION" },
{ "userId": "forloop.com","clientCode": "275","clientName": "ABC COMPANY" }]
这是我得到的样本回复。
答案 0 :(得分:0)
<强> HTML:强>
<select *ngIf='clients'>
<option *ngFor="let client of clients">{{client.clientName}}</option>
</select>
<强>代码:强>
client:Array<any>;
responseHandler(response)
{
this.client = response;
/*Response is: [{ "userId": "Mind.com","clientCode": "25","clientName": "CORPORATION" },
{ "userId": "forloop.com","clientCode": "275","clientName": "ABC COMPANY" }]*/
}