品优购电商系统开发第 5 章 五

3.3 前端代码
3.3.1 控制层
修改 goodsController.js ,在增加成功后弹出提示,并清空实体(因为编辑页面无列表)

//保存
$scope.add=function(){
goodsService.add( $scope.entity ).success(
function(response){
if(response.success){
alert('保存成功');
$scope.entity={};
}else{
alert(response.message);
}
}
);
}

3.3.2 页面
修改 goods_edit.html
引入 JS:

<script type="text/javascript" src="../plugins/angularjs/angular.min.js"> </script>
<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/controller/baseController.js"> </script>
<script type="text/javascript" src="../js/controller/goodsController.js"> </script>

定义控制器:

<body
class="hold-transition skin-red sidebar-mini"
ng-app="pinyougou"
ng-controller="goodsController">

表单部分代码:

<div class="col-md-2 title">商品名称</div>
<div class="col-md-10 data">
<input type="text" class="form-control" ng-model="entity.goods.goodsName"
placeholder="商品名称" value="">
</div>
<div class="col-md-2 title">副标题</div>
<div class="col-md-10 data">
<input type="text" class="form-control" ng-model="entity.goods.caption"
placeholder="副标题" value="">
</div>
<div class="col-md-2 title">价格</div>
<div class="col-md-10 data">
<div class="input-group">
<span class="input-group-addon">¥</span>
<input type="text" class="form-control" ng-model="entity.goods.price"
placeholder="价格" value="">
</div>
</div>
<div class="col-md-2 title rowHeight2x">包装列表</div>
<div class="col-md-10 data rowHeight2x">
<textarea rows="4" class="form-control" ng-model="entity.goodsDesc.packageList"
placeholder="包装列表"></textarea>
</div>
<div class="col-md-2 title rowHeight2x">售后服务</div>
<div class="col-md-10 data rowHeight2x">
<textarea rows="4" class="form-control" ng-model="entity.goodsDesc.saleService"
placeholder="售后服务"></textarea>
</div>

保存按钮

<button class="btn btn-primary" ng-click="add()"><i class="fa fa-save"></i> 保 存
</button>

 

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读