angularjs – 如何使用最新的$resource填充Angular UI Bootstrap
根据
thisPawe?Koz?owski的回答,来自AngularUI-Bootstrap的Typeahead应该可以在最新的Angular版本中使用$resource异步获取弹出项目时使用(我使用的是1.2.X).
Plunk – Pawe?’s version – Typeahead with $http 我想我不知道如何正确使用它(因此我在typeaheadHighlight指令的代码中得到一个错误 – typeahead将立即返回的资源作为字符串和轮胎来突出显示它们). Plunk – Typeahead with $resource 我认为关键代码是: $scope.cities = function(prefix) { var p = dataProviderService.lookup({q: prefix}).$promise; return p.then(function(response){ $log.info('Got it!'); return response.data; }); return p; }; 我尝试过很多东西 – 返回$promise(来自Plunker的版本),query(),然后(). 你可能想看看这个:https://github.com/angular/angular.js/commit/05772e15fbecfdc63d4977e2e8839d8b95d6a92d
应该:
$scope.cities = function(prefix) { return dataProviderService.lookup({q: prefix}).$promise.then( function(response){ // might want to store them somewhere to process after selection.. // $scope.cities = response.data; return response.data; }); }; 这是基于上面提到的角度提交,它在Angular 1.2.13上对我有用 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |