cobuild-angular-stack
Version:
Base stack angular sass jade gulp
57 lines (43 loc) • 1.73 kB
JavaScript
(function (module) {
'use strict';
module.controller('BannerListController', BannerListController);
BannerListController.$inject = ['$scope', '$rootScope', '$state', 'PredefinedBanner', '$uibModal', 'toastr'];
function BannerListController($scope, $rootScope, $state, PredefinedBanner, $uibModal, toastr) {
$scope.banners = PredefinedBanner.find();
$scope.refresh = function () {
$scope.banners = PredefinedBanner.find();
};
$scope.newBanner = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.banners.new.html',
controller: 'AdminBannerNewController',
size: 'md',
backdrop: 'static'
});
modalInstance.result
.then(function (banner) {
$scope.banners.push(banner);
});
};
$scope.removeBanner = function (index) {
var banner = $scope.banners[index];
PredefinedBanner
.deleteById({id: banner.id}, function () {
$scope.banners.splice(index, 1);
});
};
$scope
.$watchGroup([
'filterName',
'filterPrice.result',
'sortBy.selected.field',
'sortBy.selected.order'
], $scope.refresh);
$scope.$watchCollection('storeFilter', $scope.refresh);
$scope.$watchCollection('categoriesFilter', $scope.refresh);
$scope.create = function () {
$state.go('admin.banners.new');
};
}
})(angular.module('uniko.admin.banners'));