AngularJs實現級聯
阿新 • • 發佈:2018-12-18
//讀取模板id $scope.$watch('entity.goods.category3Id',function(newValue,oldValue){ itemCatService.findOne(newValue).success(function(response){ $scope.entity.goods.typeTemplateId = response.typeId; }); }); //查詢三級分類 $scope.$watch('entity.goods.category2Id',function(newValue,oldValue){ itemCatService.findByParentId(newValue).success(function(response){ $scope.itemCat3List = response; }); }); //查詢二級分類 $scope.$watch('entity.goods.category1Id',function(newValue,oldValue){ itemCatService.findByParentId(newValue).success(function(response){ $scope.itemCat2List = response; }); }); //查詢一級商品分類 $scope.selectItemCat1List = function(){ itemCatService.findByParentId(0).success(function(response){ $scope.itemCat1List = response; }); }
<tr> <!-- as 前面是值, 後面是文字 --> <td><select class="form-control" ng-model="entity.goods.category1Id" ng-options=" item.id as item.name for item in itemCat1List"></select></td> <td><select class="form-control select-sm" ng-model="entity.goods.category2Id" ng-options=" item.id as item.name for item in itemCat2List" ></select></td> <td><select class="form-control select-sm" ng-model="entity.goods.category3Id" ng-options=" item.id as item.name for item in itemCat3List" ></select></td> <td>模板ID:{{entity.goods.typeTemplateId}}</td> </tr>