list.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination', ////分页用到的插件
  4. 'ngSanitize'///$sanitize这个服务.此服务依赖于ngSanitize模块.(这个模块需要加载angular-sanitize.js插件)
  5. ////应用ng-bind-html如果不引用此模块,会报安全错误
  6. ]);
  7. app.controller("prjListCtrl", ["$http", "$scope", function ($http, $scope) {
  8. var self = this;
  9. var get_userid = "7ac641ab-8940-4a50-8a0e-afe1b6d1cda1";
  10. var postCfg = {
  11. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  12. transformRequest: function (data) {
  13. return $.param(data);
  14. }
  15. };
  16. ////请求api的网址
  17. self.webApiUrl = "";
  18. self.getApiUrlData = function () {
  19. var data = {
  20. }
  21. $http.get("../../config.txt", data, postCfg)
  22. .success(function (res) {
  23. self.webApiUrl = res.webApiUrl;
  24. });
  25. };
  26. self.getApiUrlData();
  27. //数据表格的控制器,动态加载table表格数据
  28. self.noDataTip = 1; //声明没有数据时变量
  29. self.rows = []; //declare an empty array
  30. self.pageno = 1; // initialize page no to 1
  31. self.total_count = 0;
  32. self.itemsPerPage = 8; //this could be a dynamic value from a drop down
  33. self.pageOptions = [8, 12, 16, 20, 24, 26]; ////
  34. self.getData = function (pageno) { // This would fetch the data on page change.
  35. self.pageno = pageno;
  36. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  37. var data = {
  38. userid:get_userid,
  39. pagesize: self.itemsPerPage,
  40. pageno: self.pageno
  41. };
  42. ///为了演示
  43. var jsonUrl = "json/list.txt?ctime="+new Date();
  44. $http.get("" + jsonUrl + "", data, postCfg)
  45. .success(function (res) {
  46. //console.log(res);
  47. if (res.Items == null || res.Items == undefined || res.Items == "") {
  48. self.noDataTip = 0;
  49. } else {
  50. self.noDataTip = 1;
  51. self.mainTableName = res.mainTableName;
  52. self.rows = res.Items; //ajax request to fetch data into self.data
  53. self.total_count = res.total_count;
  54. }
  55. });
  56. };
  57. self.getData(1);
  58. }]);