Я прошел через предыдущие решения, но это не помогло решить мою проблему.Я пытаюсь отобразить список пользовательских данных в typeahead.Я получаю сообщение об ошибке, как показано ниже, и результаты вызова API распечатываются в журнале консоли, но не отображаются в раскрывающемся списке.
в моем контроллере:
$scope.getUserDetails = function (id, value) {
var myUrl = '//myAPIcall?id=1&value=xxx';
return $http.get(myUrl).then(function successCallback(response) {
return response.data.userOptions[0].userOptionValues.map(function(item) {
console.log('item.userValue = '+item.userValue);
$scope.getUserDetails = item.userValue;
return item.userValue;
});
}, function errorCallback(response) {
console.log(response);
});
};
в моем html:
<input id="inputText"
type="text"
name="filter"
class="form-control"
data-ng-model="selectedVal"
uib-typeahead="item.userValue for item in getUserDetails(1,$viewValue) | filter:$viewValue | limitTo:10 "
typeahead-template="displayTemplate.html"/>
<script type="text/ng-template" id="displayTemplate.html">
<a>
<span bind-html-unsafe="match.label | uibTypeaheadHighlight:query"></span>
</a>
</script>
Ошибка: [filter: notarray] http://errors.angularjs.org/1.4.6/filter/notarray?p0=%7B%22%24%24state%22%3A%7B%22status%22%3A0%7D%7D в angular.min.js: 6 в angular.min.js: 149 в Object.fn [в качестве источника] (eval при компиляции(angular.min.js: 212),: 4: 610) в getMatchesAsync (ui-bootstrap-tpls-0.14.0.min.js: 6747) в ui-bootstrap-tpls-0.14.0.min.js: 6845на angular.min.js: 146 на e (angular.min.js: 43) на angular.min.js: 45
Любая помощь приветствуется!