Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('dashboardApp', [ 'ngMaterial', 'ui.bootstrap']);
- app.config(function($mdThemingProvider) {
- $mdThemingProvider.theme('default').primaryPalette('teal').accentPalette('blue');
- });
- app.controller('dashboardController', function($rootScope, $scope, $http, $location, OrderService) {
- $scope.init = function() {
- orderService.loadMyOrders();
- };
- });
- app.service('OrderService', function ($rootScope, $scope, $http, $location) {
- $scope.filteredList = [];
- $scope.currentPage = 1;
- $scope.numPerPage = 4;
- $scope.maxSize = 5;
- $scope.sort = "statusOrder";
- $scope.reverse = false;
- return{
- loadMyOrders : function() {
- $http
- .post(
- $location.absUrl() + '/orders/list',
- {
- headers : {
- 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
- }
- }).success(function(data, status) {
- $scope.message = data.message;
- $scope.isSuccess = true;
- $scope.orders = data.list;
- }).error(function(data) {
- $scope.isError = true;
- $scope.message = data.message;
- });
- },
- findOrder : function(order) {
- $scope.filtro = {
- id : order.id
- };
- $scope.loading = true;
- $http
- .post(
- $location.absUrl() + '/orders/find',
- $.param($scope.filtro),
- {
- headers : {
- 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
- }
- }).success(function(data, status) {
- $scope.message = data.message;
- $scope.isSuccess = true;
- $scope.order = data.bean;
- }).error(function(data) {
- $scope.isError = true;
- $scope.message = data.message;
- });
- },
- changeSort : function(value) {
- if ($scope.sort == value) {
- $scope.reverse = !$scope.reverse;
- return;
- }
- $scope.sort = value;
- $scope.reverse = false;
- }
- }
- $scope.$watch('currentPage + numPerPage', function() {
- var begin = (($scope.currentPage - 1) * $scope.numPerPage), end = begin
- + $scope.numPerPage;
- $scope.filteredList = $scope.list.slice(begin, end);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement