crunchbutton/www/assets/cockpit/js/controllers.order.js
2014-11-22 12:33:12 -08:00

43 lines
987 B
JavaScript

NGApp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/orders', {
action: 'orders',
controller: 'OrdersCtrl',
templateUrl: 'assets/view/orders-list.html',
reloadOnSearch: false
}).when('/order/:id', {
action: 'order',
controller: 'OrderCtrl',
templateUrl: 'assets/view/orders-order.html'
});
}]);
NGApp.controller('OrdersCtrl', function ($scope, OrderService, ViewListService) {
angular.extend($scope, ViewListService);
$scope.view({
scope: $scope,
watch: {
search: '',
restaurant: '',
community: '',
date: '',
},
update: function() {
OrderService.list($scope.query, function(d) {
$scope.orders = d.results;
$scope.complete(d);
});
}
});
});
NGApp.controller('OrderCtrl', function ($scope, $rootScope, $routeParams, $interval, OrderService) {
OrderService.get($routeParams.id, function(d) {
$rootScope.title = 'Order #' + d.id_order;
$scope.order = d;
$scope.ready = true;
});
});