A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

本帖最后由 谷粒姐姐 于 2018-8-21 14:11 编辑

商品录入【品牌选择】
2.1 需求分析
在用户选择商品分类后,品牌列表要根据用户所选择的分类进行更新。具体的逻辑是根据用户选择的三级分类找到对应的商品类型模板,商品类型模板中存储了品牌的列表 json 数据。
图片1.png
2.2 代码实现
(1)在 pinyougou-shop-web 工程创建 TypeTemplateController        (可从运营商后台拷贝)

(2)在 pinyougou-shop-web 工程创建 typeTemplateService.js        (可从运营商后台拷贝)

(3)在 goodsController 引入 typeTemplateService        并新增代码
[AppleScript] 纯文本查看 复制代码
//模板 ID 选择后 更新品牌列表

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

$scope.typeTemplate=response;//获取类型模板

$scope.typeTemplate.brandIds= JSON.parse(  $scope.typeTemplate.brandIds);//品牌列表

}

);

});
在页面 goods_edit.html 引入 js
[AppleScript] 纯文本查看 复制代码
<script type="text/javascript" src="../js/service/typeTemplateService.js">    </script>
添加品牌选择框
[AppleScript] 纯文本查看 复制代码
<select  class="form-control"  ng-model="entity.goods.brandId"  ng-options="item.id  as item.text  for  item  in  typeTemplate.brandIds"></select>

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马