UNPKG

unserver-unify

Version:

72 lines (66 loc) 2.21 kB
angular.module('bamboo.coursebundle').controller('BundleListsCtrl', function($scope, $rootScope, loginService, ApiService, deviceDetector, fullWidthService) { var self = this; var colorarray = ['panel-grey', 'panel-red', 'panel-blue', 'panel-sea', 'panel-green', 'panel-orange']; this.pageSize = 9; self.showMobileSid = false; //init the var to show/hide sidebar for mobile view self.toggleSideBar = function() { self.showMobileSid = !self.showMobileSid; } this.picUrl = ApiService.SHOST + "/bundlephotos/"; this.defaultCoursePhoto = ApiService.SHOST + "/public/images/videos.png"; var page = 1; var option; // this.sortmethod = this.tab || "visitercounter"; this.pageChanged = function(newPage) { page = newPage; getInfo(); }; this.nextPage = function() { page++; getInfo(); } self.currency = (loginService.school.currency&&loginService.school.currency.sign)?loginService.school.currency.sign:'$'; function getInfo() { var info = { action: "getPublishBundles", start: (page - 1) * (self.pageSize || 9), limit: self.pageSize || 9, // search: searchmethod, }; console.log(info); if (self.option) { // info.search = { // category: self.option, // } if(info.search ){ angular.extend(info.search,{category: self.option}); }else{ info.search = { category: self.option, } } } console.log(info); ApiService.post('/coursebundle', info).then(function(result) { self.bundles = result.data.data.items; //$scope.displayCourses =[].concat($scope.courses); $scope.totalCount = result.data.data.counter; angular.forEach(self.bundles, function(item, index) { if (item.photo) { item.photourl = self.picUrl +item._id+'/'+ item.photo; } else { item.photourl = self.defaultCoursePhoto; } }) console.log(self.bundles); }); } getInfo(); this.list = function(key, title) { console.log(key, title); self.courses = []; self.option = key; page = 1; getInfo(); }; });