'use strict'; var CashFlowController = ['$scope', '$routeParams', '$location', 'asDateFilter', 'cashFlow', function ($scope, $routeParams, $location, asDate, cashFlow) { $scope.info = cashFlow; $scope.show = function () { var startDate = asDate($scope.info.StartDate), finishDate = asDate($scope.info.FinishDate); $location.path('/CashFlow').search({StartDate: startDate, FinishDate: finishDate}); }; $scope.foDate = true; }]; CashFlowController.resolve = { cashFlow: ['$route', 'CashFlow', function ($route, CashFlow) { var id = $route.current.params.id, startDate = $route.current.params.StartDate, finishDate = $route.current.params.FinishDate; if (angular.isUndefined(startDate) || angular.isUndefined(finishDate)) { return CashFlow.get({}).$promise; } else if (angular.isUndefined(id)) { return CashFlow.get({StartDate: startDate, FinishDate: finishDate}).$promise; } else { return CashFlow.get({id: id, StartDate: startDate, FinishDate: finishDate}).$promise; } }] };