黑马程序员技术交流社区

标题: 【郑州校区】Java之品优购课程讲义_day06(2) [打印本页]

作者: 谷粒姐姐    时间: 2018-8-20 12:10
标题: 【郑州校区】Java之品优购课程讲义_day06(2)
1.1.1 二级分类下拉选择框
在 goodsController 增加代码:
[AppleScript] 纯文本查看 复制代码
//读取二级分类

$scope.$watch('entity.goods.category1Id',  function(newValue,  oldValue)  {

//根据选择的值,查询二级分类itemCatService.findByParentId(newValue).success(

function(response){

$scope.itemCat2List=response;

}

);

});
$watch 方法用于监控某个变量的值,当被监控的值发生变化,就自动执行相应的函数。修改 goods_edit.html 中二级分类下拉框

1.1.1 [img=570,66]三级分类下拉选择框
在 goodsController 增加代码:
[AppleScript] 纯文本查看 复制代码
//读取三级分类

$scope.$watch('entity.goods.category2Id',  function(newValue,  oldValue)  {
//根据选择的值,查询二级分类itemCatService.findByParentId(newValue).success(

function(response){

$scope.itemCat3List=response;

}

);

});
[img=40,24]修改 goods_edit.html 中三级分类下拉框
<
select
class="form-controlselect-sm"ng-model="entity.goods.category3Id"
ng-options="item.idasitem.nameforiteminitemCat3List"></select>
1.1.1 读取模板 ID
在 goodsController 增加代码:
[AppleScript] 纯文本查看 复制代码
//三级分类选择后 读取模板 ID

$scope.$watch('entity.goods.category3Id',  function(newValue,  oldValue)  { itemCatService.findOne(newValue).success(
function(response){

$scope.entity.goods.typeTemplateId=response.typeId; //更新模板 ID

}

);

});
在 goods_edit.html 显示模板 ID
[AppleScript] 纯文本查看 复制代码
模板 ID:{{entity.goods.typeTemplateId}}






欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2