ui.select给出重复的错误,然后在$ index添加的跟踪时未定义

时间:2016-01-09 15:46:17

标签: javascript angularjs

我正在使用ui.select提出一些问题。

使用以下代码:

<ui-select multiple ng-model="$storage.SelectedClients" theme="bootstrap" style="width: 300px;">
    <ui-select-match placeholder="Search and select Clients...">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="client in $storage.Clients | propsFilter: {name: $select.search}">
        <div ng-bind-html="client.name | highlight: $select.search"></div>
        <small>
      email: {{client.email}}
      </small>
    </ui-select-choices>
</ui-select>

除非我有一个同名的客户,否则工作正常。然后我得到:

enter image description here

所以我在重复结束时添加track by $index以获得新错误。

enter image description here

我已经尝试通过其他我知道的独特事物进行跟踪但是我总是收到此错误。

我的研究指出了类似的事情,但是没有什么对我有用:

此处研究: https://github.com/angular-ui/ui-select/issues/870 https://github.com/angular-ui/ui-select/issues/219 https://github.com/angular-ui/ui-select/issues/380

非常感谢

1 个答案:

答案 0 :(得分:0)

您可以尝试添加此条件

if(matches!=null && matches.length>0 && result[matches[1]] == value[matches[1]]){

/ *在这里写下您的代码* /

}