我在标签输入中使用自动完成功能,但是当我开始编写时,我收到此错误:array1.filter 不是函数。这是我的 Angular 调用
$scope.loadTags = function(query) {
var searchPeople = $scope.baseUrl + "&searchString=";
return $http.get(searchPeople + query, {
}).success(function (data) {
$scope.people = data.data.data;
console.log($scope.people);
}).error(function (data){
console.log("Error");
});
};
此外,我不知道如何从 $scope.people json 中检索值,如下所示:
{
"id": 17,
"cod": "gg117",
"name": "Alex"
}
我知道我需要一个自定义模板,但只要我收到错误,我就无法做到这一点。顺便说一句,模板是这个,但我不知道它是否正确
<script type="text/ng-template" id="my-custom-template">
<div class="left-panel">
<img ng-src="./img/avatar.jpeg" />
</div>
<div class="right-panel">
<span ng-bind-html="$highlight($getDisplayText())"></span>
<span>({{people.name}})</span>
</div>
</script>
最佳答案
您需要传递一个 promise ,其中包含格式的数据
{
"data":[{'text':'tag1'}, {'text', 'tag1'}]
}
关于javascript - array1.filter 不是函数 ng-tags-input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31182154/