【问题标题】:How can i use Data of a url to show as an option in dropdown?如何使用 url 的数据在下拉列表中显示为选项?
【发布时间】:2019-03-19 08:26:54
【问题描述】:

这里我有一个包含数据数组列表的 url。现在我要做的是我需要从这个 url 获取数据以显示为下拉列表中的一个选项并选择需要的那个。我知道它可以通过使用 Get 方法,但我做不到。请帮助我。我希望我清楚我的疑问,如果有混淆请告诉我。

url:https://api.myjson.com/bins/l8asa

这是提供的网址。需要在下拉菜单中获取此网址的详细信息。 提前谢谢..!!

【问题讨论】:

标签: angular get dropdown


【解决方案1】:

虽然从你的问题中不清楚你真正想要做什么,但我试图猜测。看看它是否有帮助。 将 url 的响应存储到变量中,然后在 template(html) 中使用 for 循环。

Components.ts

 res => {
    console.log(res);
    this.data = res;
  }

Component.html

<tr  *ngFor="let i of data;" mdbTableCol ><td style="float:left">
<a class="dropdown-item waves-light" mdbWavesEffect><strong>{{ i.classid }}</strong> 
</a>
<a class="dropdown-item waves-light" mdbWavesEffect><strong>{{ i.url }}</strong></a>
 </td>
 </tr>

【讨论】:

    猜你喜欢
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-28
    • 2015-11-29
    • 1970-01-01
    相关资源
    最近更新 更多