product-ctrl.js
angular.modules('myApp').controller('ProductCtrl',['$scope','$rootScope','$timeout','$state','$istore','$modal','$number','ProductService',
functon($scope,$rootScope,$timeout,$state,$istore,$modal,$number,ProductService){
//全局参数
$scope.page = 0;
$scope.key = ";
//获取分类
$scope.showCateList = function(){
if(!$scope.first){
var promise = ProductService.getCateGoryInfo();
promise.then(function(result){
var cateData = result.dataList;
var first = [],seconds = [];
cateData.foeEach(function(item){
if (item.level === '1') firsts.push(item);
if (item.level === '2') seconds.push(item);
})
firsts.foeEach(function(item){
var childs = findChild(item,seconds);
item.child = childs
})
function findChilds(firsts,seconds){
var childs = [];
seconds.forEach(function(item){
if (item.pId === first.id) childs.push(item)
})
return childs;
}
$scope.firsts = firsts;
if (firsts.length > 0) {
$scope.firstChecked = firsts[0];
$scope.seconds = $scope.firstChecked.childs;
}
})
}
$scope.showSearchTypeBody = true;
}
$scope.changeSearchType = function(first){
$scope.firstChecked = first;
$scope.seconds = first.childs;
}
$scope.checkSecond = function(secondChecked){
$scope.secondChecked = secondChecked;
}
}])
//product-ctrl.js
angular.modules('myApp').controller('ProductCtrl',['$scope','$rootScope','$timeout','$state','$istore','$modal','$number','ProductService',
functon($scope,$rootScope,$timeout,$state,$istore,$modal,$number,ProductService){ //全局参数 $scope.page = 0; $scope.key = ''; //获取分类,分类有一级分类与一级分类下的分类 $scope.showCateList = function(){ if(!$scope.first){ var promise = ProductService.getCateGoryInfo(); promise.then(function(result){ var cateData = result.dataList; var firsts = [],seconds = [];cateData.foeEach(function(item){if (item.level === '1') firsts.push(item);if (item.level === '2') seconds.push(item);})firsts.foeEach(function(item){var childs = findChild(item,seconds);item.child = childs})
function findChilds(firsts,seconds){var childs = [];seconds.forEach(function(item){if (item.pId === first.id) childs.push(item)})return childs;}
$scope.firsts = firsts;if (firsts.length > 0) {$scope.firstChecked = firsts[0];$scope.seconds = $scope.firstChecked.childs;} }) }$scope.showSearchTypeBody = true; }$scope.changeSearchType = function(first){$scope.firstChecked = first;$scope.seconds = first.childs;}$scope.checkSecond = function(secondChecked){$scope.secondChecked = secondChecked;}
}])