我正在尝试使用角度 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 中,并且不一致:
- {{tag.description}} 和/或 tag.label 不由 angular 处理并按下拉选项列表中的原样打印。
- 占位符(“添加新标签...”)未在 IE8 和 IE9 中呈现
任何帮助将不胜感激!谢谢。
刷新标签:
$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;
});
}
};