我正在努力为类似于here的文本框实现自动完成功能。主要区别在于我希望我的服务返回列表。这是我使用的代码...
//How I would like it to work...
$scope.search=function(query){
$http.get('/product/query/name%3A'+query+'*').success(function(data){
// For a data is ["a","a1"]
$scope.names = data;
})
}
//Trying to get it to work by not using the ng-change event but still no dice
$http.get('/product/query/name%3A*').success(function(data){
//Data when printed does in fact match the ["a","a1", "b"]
$scope.names = data;
});
//finally this DOES work but not dynamic
$scope.names =["a","a1", "b"];
任何人都可以提供一些关于我缺少什么的见解吗?
答案 0 :(得分:2)