unserver-unify
Version:
56 lines (51 loc) • 1.47 kB
JavaScript
angular.module('bamboo.company').controller('DepartmentListCtrl', function($scope, ApiService, $stateParams, $state) {
var _self = this;
console.log("---- DepartmentListCtrl -----");
this.defaultPhoto = "assets/images/company.png";
this.schoolurl=ApiService.SHOST + "/public/" + ApiService.RES + "/school/" + ApiService.gid + "/";
this.key=$stateParams.key;
this.items = [];
this.itemNumber = 6;
$scope.currentPage=1;
this.page = 0;
this.zones = ApiService.school.zones;
this.criteria = '';
this.q;
$scope.setting = {
listName: "company",
pageSize: _self.itemNumber,
currentPage: (_self.page + 1)
};
var currentkey;
this.totalnumber=0;
this.total=0;
this.alldeps=[];
function getDepartments(){
ApiService.get('/departments').then(function(result) {
console.log(result);
if (result.data.success) {
console.log(result.data.data);
_self.items=_self.alldeps=result.data.data;
_self.total=_self.totalnumber=result.data.data.length;
if(_self.key){
_self.list(_self.key);
}
}
});
}
getDepartments();
this.list = function(key) {
if(!key){
_self.items=_self.alldeps;
return;
}
console.log(key);
var items=[];
angular.forEach(_self.alldeps,function(dep,index){
if(dep.zone==key){
items.push(dep);
}
});
_self.items=items;
};
});