angularjs数据请求、分页问题
来源:互联网 发布:淘宝网卖家体检中心 编辑:程序博客网 时间:2024/05/18 00:15
<tm-pagination conf="paginationConf"></tm-pagination><script src="../lib/angularjs/1.2.22/angular.min.js"></script><script src="../src/pagination/tm.pagination.js"></script>
这个是我引用他人的分页插件的,由于在请求数据方面出现问题,所以做了变动
原创:https://www.miaoyueyue.com/archives/833.html
下面是我的处理方式:
<script type="text/javascript"> var app = angular.module('dataHall', ['tm.pagination']); app.controller('dataHallCtrl', ['$scope', '$http', function ($scope, $http) { //配置分页基本参数 $scope.paginationConf = { currentPage: 1, itemsPerPage: 5 }; ////isloading ==1:加载数据2:查询不到数据3:查询到数据 $scope.isloading = function (isloading) { if (isloading == 1) { $(".loading").show(); $("#noneData").hide(); } else if (isloading == 2) { $(".loading").hide(); $("#noneData").show(); } else { $(".loading").hide(); $("#noneData").hide(); $(".datainit").show(); } }; var GetAllEmployee = function () { var postData = { pageNo: $scope.paginationConf.currentPage, pageSize: $scope.paginationConf.itemsPerPage }; $http({ url: "yoururl", method: 'post', params: postData }).success(function (response) { $scope.paginationConf.totalItems = response.value.count; $scope.data = response.value.list; if (!$scope.data) { // $scope.isloading(2); } else { // $scope.isloading(3); } }); }; /*************************************************************** 当页码和页面记录数发生变化时监控后台查询 如果把currentPage和itemsPerPage分开监控的话则会触发两次后台事件。 ***************************************************************/ $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage', GetAllEmployee); }]);</script>
其他的处理方式:
AngularJS 的POST请求 默认Content-Type是”application/json”,并不是表单形式的”application/x-www-form-urlencoded”提交,服务端接收到的是对象,而不是字段,当然对于RESTful接口来说,正好需要对象,SpringMVC通过@RequestBody注解就可以得到相应对象,很是方便。
如果需要使用传统方式,可以设置Content-Type
$http.post('/login/in', $.param({username: $scope.username, password: $scope.password}), {headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}}) .then(function (response) { if (response.data.success) { console.log("登录成功"); } else { console.log(response.data.msg); } });
$.param是JQuery方法,将js对象转成username=username&password=password形式
阅读全文
0 0
- angularjs数据请求、分页问题
- AngularJs分页加载数据
- angularjs分页的相关问题
- angularjs 跨域请求问题
- AngularJS 用 $http.jsonp 方法跨域请求数据错误的问题
- AngularJS 用 $http.jsonp 方法跨域请求数据错误的问题
- Angularjs $http 请求数据(get.post)
- php + angularjs $http get 请求 显示数据
- angularjs $http请求数据序列化
- AngularJs——$http请求数据
- AngularJS中的$http服务请求数据
- 解决AngularJS Http请求参数问题
- angularJs使用$q服务进行同步请求数据,解决异步获取数据导致return返回为空的问题
- angularjs分页
- angularjs分页
- 关于分页插件pagination的应用及遇到的问题(用ajax请求数据进行拼接后分页显示)
- 网络请求数据问题
- 前端开发-数据分页请求和删除
- 三、渲染元素
- Android如何使用XML创建一个环形渐变颜色图片
- <NOIP> 15 . P1428 小鱼比可爱
- ActionBar标题居中
- java.lang.OutOfMemoryError: Java heap space解决方法
- angularjs数据请求、分页问题
- 在VC2015里包含了lib库,但没有设置对路径的出错
- RGB565转换为RGB88,并作线性补偿
- HDU 4704 Sum(费马小定理,组合数学,快速幂)
- leetcode--evaluate-reverse-polish-notation
- 我的C++学习之路
- 多线程问题总结
- Oracle 导出导入数据
- 四、组件化和属性(props)