Javascript 前角打印机未按预期工作
我正在尝试使用Typeahead的Angular指令在我的数据库中加载和搜索。问题是,当我搜索时,建议只显示“未定义” 我的HTML如下所示:Javascript 前角打印机未按预期工作,javascript,angularjs,angular-ui-typeahead,Javascript,Angularjs,Angular Ui Typeahead,我正在尝试使用Typeahead的Angular指令在我的数据库中加载和搜索。问题是,当我搜索时,建议只显示“未定义” 我的HTML如下所示: <h4>Asynchronous results</h4> <pre>Model: {{asyncSelected | json}}</pre> <input type="text" ng-model="asyncSelected"
<h4>Asynchronous results</h4>
<pre>Model: {{asyncSelected | json}}</pre>
<input type="text" ng-model="asyncSelected" placeholder="Locations loaded via $http" typeahead="person for object in getLocation($viewValue)" typeahead-loading="loadingLocations" typeahead-no-results="noResults" class="form-control">
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found
</div>
我最终会尝试按姓名和地址进行筛选,但我想我需要先让基础知识发挥作用
如果您对如何解决此问题有任何建议,我们将不胜感激。请尝试分配列表 //你在这里编码 $scope.viewvalue='?'; $scope.list=$scope.getLocation($scope.viewvalue) //html //typeahead=“列表中对象的人员”
$scope.getLocation = function(val) {
var data = {
searchString: val
};
return $http.post('/api/search', data).then(function(response){
console.log(transformSearchResults(response));
/*Returns an array of objects like this:
[
{
name: "Peter Pan",
address: "Neverland 944"
}
]
*/
return transformSearchResults(response);
});
};