【发布时间】:2018-06-19 20:57:09
【问题描述】:
使用 AngularJS 1.3.4。
我有一个从 web api 填充的 html 表,我在其中发出 http 请求以获取该数据并填充我的 html 表。我的示例 json 如下:
{
id: 1,
firstName: "John",
lastName: "Rein",
status: 'available'
},
{
id: 2,
firstName: "David",
lastName: "Gumry",
status: 'not available'
}
现在我在表格下方有一个下拉菜单,并且我正在使用 ui-select 。我想根据我的 json 中的状态填充这个下拉列表。例如,在我上面的 json 中,我有 2 个状态可用和不可用。我希望我的下拉列表具有这些值。填充下拉列表后,我想根据选择的下拉列表值过滤我的表。我的下拉列表为:
<ui-select tagging ng-model="selected" theme="bootstrap">
<ui-select-match placeholder="Pick one...">{{$select.selected.value}}</ui-select-match>
<ui-select-choices repeat="val in values | filter: $select.search track by val.value">
<div ng-bind="val.value | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
我在以下位置创建了我的 jsfiddle: https://jsfiddle.net/aman1981/wfL1374x/
我不确定如何将结果从 json 绑定到我的 DDL 并过滤我的表。
【问题讨论】:
-
您的 jsfiddle 的链接已损坏
-
@jbrown 我已经解决了。