angularstrap typeahead 处理异步数据
来源:互联网 发布:ubuntu jdk gz 安装 编辑:程序博客网 时间:2024/06/06 17:43
使用 angularstrap typeahead 的时候下拉列表总是比输入的数据慢一步,注意下你的代码
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" /><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script><script src="//mgcrea.github.io/angular-strap/dist/angular-strap.js" data-semver="v2.1.3"></script><script src="//mgcrea.github.io/angular-strap/dist/angular-strap.tpl.js" data-semver="v2.1.3"></script><body ng-app="app"> <div ng-controller="firstCtrl"> <div class="form-group"> <label><i class="fa fa-home"></i> Address <small>(async via maps.googleapis.com)</small> </label> <input type="text" class="form-control" ng-model="selectedAddress" data-animation="am-flip-x" ng-options="address.formatted_address as address.formatted_address for address in getAddress($viewValue)" placeholder="Enter address" bs-typeahead> </div> </div></body>
var app = angular.module('app', ['mgcrea.ngStrap']);app.controller('firstCtrl', function($scope, $http) { $scope.getAddress = function(viewValue) { var params = { address: viewValue, sensor: false }; return $http.get('http://maps.googleapis.com/maps/api/geocode/json', { params: params }) .then(function(res) { return res.data.results; }); };});
需要注意数据源使用
getAddress($viewValue)
处理请求使用
then
监听选中列表的事件,加在你自己的控制器里即可
$scope.$on('$typeahead.select', function(value, index) { console.log(value); console.log(index);}
参考自 :点击打开链接
1 0
- angularstrap typeahead 处理异步数据
- JSON异步处理数据
- Servlet异步处理数据
- android异步处理数据
- jquery 异步数据的处理
- AngularStrap -- Modal
- AngularStrap -- Popovers
- 详谈 Jquery Ajax 异步处理Json数据.
- 详谈 Jquery Ajax 异步处理Json数据.
- 详谈 Jquery Ajax 异步处理Json数据.
- 详谈 Jquery Ajax异步处理Json数据.
- 详谈 Jquery Ajax 异步处理Json数据.
- 详谈 Jquery Ajax 异步处理Json数据.
- 详谈 JQuery Ajax异步处理Json数据
- 详谈 Jquery Ajax 异步处理Json数据
- 详谈 Jquery Ajax异步处理Json数据
- 详谈 Jquery Ajax 异步处理Json数据
- 代码分析ADO.NET数据异步处理
- Error:Execution failed for task ':app:buildInfoDebugLoader'. > Exception while doing past iteration
- 使用 matlab 数字图像处理(一)—— 归一化直方图
- 射线及其碰撞检测 [代码清单6-7]
- Android开源之BaseRecyclerViewAdapterHelper(持续更新!)
- 第七周总结及Boostrap框架demo
- angularstrap typeahead 处理异步数据
- What is the HINSTANCE passed to CreateWindow and RegisterClass used for?
- 线程与进程
- 怎样使用nat和桥接方式解决虚拟机联网问题(一)
- 安装eclipse的JRebel6.0.3的插件
- spring框架整合ibatis的项目实例代码
- iOS调用系统闪光灯以及实时修改屏幕亮度
- IOS摇晃处理流程
- VBA批量调整图片宽度