main_publish.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. var app = angular.module('myApp', ['angularUtils.directives.dirPagination', 'mgcrea.ngStrap', 'ngTable']);
  2. app.factory('dataService', function($http, $q){
  3. return{
  4. getData: function(){
  5. var deferred = $q.defer();
  6. $http({
  7. method: 'GET',
  8. url: '/publish'
  9. }).success(function(data, status, headers, config) {
  10. //console.log(data);
  11. deferred.resolve(data);
  12. }).
  13. error(function(data, status, headers, config) {
  14. deferred.reject(status);
  15. });
  16. return deferred.promise;
  17. }
  18. }
  19. });
  20. app.controller('QuestionController',
  21. function QuestionController($scope, dataService, $location){
  22. var promiseObj=dataService.getData();
  23. promiseObj.then(function(value)
  24. {
  25. $scope.data=value.reverse();
  26. });
  27. $scope.sort = function(keyname)
  28. {
  29. $scope.sortKey = keyname; //set the sortKey to the param passed
  30. $scope.reverse = !$scope.reverse; //if true make it false and vice versa
  31. }
  32. $scope.rowLink = function(e)
  33. {
  34. console.log('rowLink', e);
  35. //$location.absUrl("/publishing/view?id=" + e);
  36. window.open("/publishing/view?id=" + e, e)
  37. }
  38. }
  39. )
  40. app.controller("dynamicDemoController", dynamicDemoController);
  41. dynamicDemoController.$inject = ["NgTableParams", "dataService"];
  42. function dynamicDemoController(NgTableParams, dataService) {
  43. var promiseObj=dataService.getData();
  44. console.log('promiseObj', promiseObj);
  45. promiseObj.then(function(value)
  46. {
  47. this.simpleList=value;
  48. this.cols = [{
  49. field: "user_id",
  50. title: "user_id",
  51. sortable: "user_id",
  52. show: false,
  53. groupable: "user_id"
  54. }, {
  55. field: "userName",
  56. title: "userName",
  57. sortable: "userName",
  58. show: true,
  59. groupable: "userName"
  60. }, {
  61. field: "statusName",
  62. title: "statusName",
  63. sortable: "statusName",
  64. show: true,
  65. groupable: "statusName"
  66. }, {
  67. field: "lotName",
  68. title: "lotName",
  69. sortable: "lotName",
  70. show: true
  71. }, {
  72. field: "id",
  73. title: "id",
  74. sortable: "id",
  75. show: true
  76. }, {
  77. field: "endBidding",
  78. title: "endBidding",
  79. sortable: "endBidding",
  80. show: true
  81. }];
  82. this.tableParams = new NgTableParams({
  83. // initial grouping
  84. group: {
  85. user_id: "desc"
  86. }
  87. }, {
  88. dataset: this.simpleList,
  89. groupOptions: {
  90. isExpanded: false
  91. }
  92. });
  93. console.log('this.simpleList', this.simpleList);
  94. });
  95. }