| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- var app = angular.module('myApp', ['angularUtils.directives.dirPagination', 'mgcrea.ngStrap', 'ngTable']);
- app.factory('dataService', function($http, $q){
- return{
- getData: function(){
- var deferred = $q.defer();
- $http({
- method: 'GET',
- url: '/publish'
- }).success(function(data, status, headers, config) {
- //console.log(data);
- deferred.resolve(data);
- }).
- error(function(data, status, headers, config) {
- deferred.reject(status);
- });
-
- return deferred.promise;
- }
- }
- });
- app.controller('QuestionController',
- function QuestionController($scope, dataService, $location){
-
- var promiseObj=dataService.getData();
- promiseObj.then(function(value)
- {
- $scope.data=value.reverse();
- });
-
- $scope.sort = function(keyname)
- {
- $scope.sortKey = keyname; //set the sortKey to the param passed
- $scope.reverse = !$scope.reverse; //if true make it false and vice versa
- }
- $scope.rowLink = function(e)
- {
- console.log('rowLink', e);
- //$location.absUrl("/publishing/view?id=" + e);
- window.open("/publishing/view?id=" + e, e)
- }
-
-
- }
-
- )
- app.controller("dynamicDemoController", dynamicDemoController);
- dynamicDemoController.$inject = ["NgTableParams", "dataService"];
- function dynamicDemoController(NgTableParams, dataService) {
- var promiseObj=dataService.getData();
- console.log('promiseObj', promiseObj);
- promiseObj.then(function(value)
- {
- this.simpleList=value;
-
-
- this.cols = [{
- field: "user_id",
- title: "user_id",
- sortable: "user_id",
- show: false,
- groupable: "user_id"
- }, {
- field: "userName",
- title: "userName",
- sortable: "userName",
- show: true,
- groupable: "userName"
- }, {
- field: "statusName",
- title: "statusName",
- sortable: "statusName",
- show: true,
- groupable: "statusName"
- }, {
- field: "lotName",
- title: "lotName",
- sortable: "lotName",
- show: true
- }, {
- field: "id",
- title: "id",
- sortable: "id",
- show: true
- }, {
- field: "endBidding",
- title: "endBidding",
- sortable: "endBidding",
- show: true
- }];
- this.tableParams = new NgTableParams({
- // initial grouping
- group: {
- user_id: "desc"
- }
- }, {
- dataset: this.simpleList,
- groupOptions: {
- isExpanded: false
- }
- });
- console.log('this.simpleList', this.simpleList);
- });
- }
|