我正在尝试自动完成,其中数据来自url。我已编写代码但显示未定义。任何人都可以帮我解决此问题
//html file
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<meta charset="UTF-8">
<title>Autocomplete using remote searching</title>
<script src="angularfiles/angular.min.js"></script>
<script src="angularfiles/angular-animate.js"></script>
<script src="angularfiles/ui-bootstrap-tpls-0.13.4.js"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="Jsfiles/autourl.js"></script>
</head>
<body ng-controller="controller">
<div class="ui-widget">
<input type="text" ng-model="asyncselected" typeahead="r.city for r in getlist($viewValue)" typeahead-loading="loadingLocations" typeahead-no-results="noResults">
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found
</div>
</div>
</body>
</html>
//Js file
var app=angular.module("myapp",['ui.bootstrap']);
app.controller("controller",['$scope','$http',function($scope,$http){
$scope.getlist=function(val){
return $http.get("http://www.w3schools.com/angular/customers.php").then(function(response){
return response.data.results.map(function(item){
return item.City;
});
});
};
}]);
可能是jsfile代码有些什么不对。我无法识别。任何人都可以帮我解决。