AngularJs实现级联

//读取模板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>

猜你喜欢

转载自blog.csdn.net/weixin_42195284/article/details/84255702