我有一个包含 10,000 个对象的数组,每次单击选择时它都会使浏览器崩溃。无论如何限制 ui-select
一次只在屏幕上显示 10 个?此外,我使用的库是 ui-select .
<ui-select ng-model="ed.main.user.UserID.selected" theme="bootstrap">
<ui-select-match placeholder="{{main.editTicket.UserDisplayName}}">
{{$select.selected.DisplayName}}
</ui-select-match>
<ui-select-choices repeat="t in main.users |filter:$select.search"value="{{$selected.UserID}}">
<div ng-bind-html="t.DisplayName | highlight: $select.search"></div>
<small ng-bind-html="t.UserID | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
最佳答案
查看 limitTo例如...
<select ng-model="model" ng-options="o as o for o in items | limitTo: 10"></select>
JSFiddle Link - 演示
根据您的更新,修改您的repeat
<ui-select-choices repeat="t in main.users | filter:$select.search | limitTo: 10"value="{{$selected.UserID}}">
<div ng-bind-html="t.DisplayName | highlight: $select.search"></div>
<small ng-bind-html="t.UserID | highlight: $select.search"></small>
</ui-select-choices>
关于javascript - 如何限制与我的 Angular ui-select 链接的 10,000 个对象的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33090118/