Angular 2打字稿:如何根据单选按钮后端值显示下拉列表

时间:2017-02-16 08:11:16

标签: html css angular typescript

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" }]

这是我得到的样本回复。

1 个答案:

答案 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" }]*/
}