<script type="text/javascript" src="../js/base.js"></script>
<script type="text/javascript" src="../js/service/goodsService.js"></script>
<script type="text/javascript" src="../js/service/itemCatService.js"></script>
<script type="text/javascript" src="../js/controller/baseController.js"></script>
<script type="text/javascript" src="../js/controller/goodsController.js"></script>
//读取一级分类
$scope.selectItemCat1List=function(){
itemCatService.findByParentId(0).success(
function(response){
$scope.itemCat1List=response;
}
);
}
<body
class="hold-transition skin-red sidebar-mini"
ng-app="pinyougou"
ng-controller="goodsController" ng-init="selectItemCat1List()">
<select class="form-control" ng-model="entity.goods.category1Id" ng-options="item.id
as item.name for item in itemCat1List"></select>
//读取二级分类
$scope.$watch('entity.goods.category1Id', function(newValue, oldValue) {
//根据选择的值,查询二级分类
itemCatService.findByParentId(newValue).success(
function(response){
$scope.itemCat2List=response;
}
);
});
<select
class="form-control select-sm"
ng-model="entity.goods.category2Id"
ng-options="item.id as item.name for item in itemCat2List"></select>
//读取三级分类
$scope.$watch('entity.goods.category2Id', function(newValue, oldValue) {
//根据选择的值,查询二级分类
itemCatService.findByParentId(newValue).success(
function(response){
$scope.itemCat3List=response;
}
);
});
<select
class="form-control select-sm"
ng-model="entity.goods.category3Id"
ng-options="item.id as item.name for item in itemCat3List"></select>
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |