我正在尝试使用angular ng-repeat指令渲染一些JSON数据。它是一个项目数组,每个项目都有标签数组以及其他项目数据。 我正在使用angular-ui / select-ui来用select2渲染标签。 Select2元素使用角度控制器中预定义的可用标记数组(tagList):
<ui-select multiple ng-model="element.tags" ng-change="addTag(element.tags, $index)" theme="select2">
<ui-select-match ui-lock-choice="$item.locked" placeholder="Add new tag..." value="Add new tag...">
<div style="color: {{$item.color}};">
{{$item.label}}
</div>
</ui-select-match>
<ui-select-choices refresh="refreshTags($select.search, element.itemTags, $index)" refresh-delay="0"
repeat="tag in tagList[$index] | filter: $select.search">
<div ng-bind-html="tag.label | filter: $select.search"></div>
<small>
{{tag.description}}
</small>
</ui-select-choices>
</ui-select>
问题出在IE8中并且不一致:
任何帮助将不胜感激! 感谢。
refreshTags:
$scope.refreshTags = function (term, tags, index)
{
var labels = [];
$scope.tagList[index] = $scope.tagSource;
tags.forEach(function (item) {
labels.push(item.label);
});
if (labels.length) {
$scope.tagList[index] = $scope.tagList[index].filter(function(tag) {
return labels.indexOf(tag.label) == -1;
});
}
if (term.length) {
$scope.tagList[index] = $scope.tagList[index].filter(function(tag) {
return tag.label.indexOf(term) > -1;
});
}
};