gpt4 book ai didi

html - Angular 2 typescript :How to show dropdown list based on radio buttons backend values

转载 作者:行者123 更新时间:2023-11-28 04:19:51 25 4
gpt4 key购买 nike

UI 包含单选按钮 YES 和 NO 以及下拉菜单,我已经为单选按钮创建了后端 API 服务,我在其中使用 URL(GET) 动态发送 YES 和 NO 参数值,如果用户发送 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" }]

这是我收到的示例响应。

最佳答案

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

关于html - Angular 2 typescript :How to show dropdown list based on radio buttons backend values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42268257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com