1. 程式人生 > >Java之品優購課程講義_day05(3)

Java之品優購課程講義_day05(3)

新增商品分類(學員實現)

實現商品分類,如下圖:

當前顯示的是哪一分類的列表,我們就將這個商品分類新增到這個分類下。

實現思路:我們需要一個變數去記住上級 ID,在儲存的時候再根據這個 ID 來新增分類修改 itemCatController.js,        定義變數

[AppleScript] 純文字檢視 複製程式碼

?

1

$scope.parentId=0;//上級 ID

查詢時記錄上級 ID

//根據上級 ID 顯示下級列表
 
$scope.findByParentId=function(parentId){
 
$scope.parentId=parentId;//記住上級 ID itemCatService.findByParentId(parentId).success(
 
function(response){
 
 
$scope.list=response;
 
 
}
);
 
 
}

儲存的時候用到此變數

<div  class="modal-body">
 
 
<table  class="table  table-bordered  table-striped"    width="800px">
 
<tr>
 
<td>上級商品分類</td>
 
<td>
 
 
{{entity_1.name}}  >>    {{entity_2.name}}
 
 
</td>
 
 
</tr>
 
 
<tr>
 
<td>商品分類名稱</td>
 
<td><input    class="form-control"  ng-model="entity.name"
placeholder="商品分類名稱">    </td>
 
</tr>
 
 
<tr>
 
<td>型別模板</td>
 
<td>
 
<input  ng-model="entity.typeId"  placeholder="商品型別模板"
class="form-control"  type="text"/>
 
 
</td>
 
 
</tr>
 
 
</table>
 
 
</div>
 
 
<div  class="modal-footer">
 
 
<button  class="btn  btn-success"  data-dismiss="modal"  aria-hidden="true"
ng-click="save()">儲存</button>
 
<button  class="btn  btn-default"  data-dismiss="modal"  aria-hidden="true">
關閉</button>
 
</div>

實現型別模板下拉列表的程式碼略

1.2 修改商品分類(學員實現)

修改 item_cat.html 的修改按鈕