来自文档:
<tags-input>
<auto-complete
source="{expression}"
>
</auto-complete>
</tags-input>
表达式的结果必须是最终解析为对象数组的 promise 。
$scope.loadSuperheroes = function(query) {
// An arrays of strings here will also be converted into an
// array of objects
return $http.get('superheroes.json');
};
但是我在 $scope 中已经有了一个对象数组。但结构不同:
$scope.superheroes = [{"id":1, "name":"Batman"}, {"id":2, "name":"Superman"}]
如何在 html 中使用 $scope.superheroes.name 中的列表?
最佳答案
您可以通过设置 displayProperty
属性来更改用于显示标签文本的属性:
<tags-input ng-model="tags" display-property="name"></tags-input>
autocomplete
指令也将使用该属性来显示返回的建议。
关于javascript - 如何选择要在 ng-tags-input 自动完成中显示的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26780149/