功能:规格选项的新增和删除功能
编写controller代码
//定义一个组合实体类对象
$scope.entity={specification:{},specificationOptionList:[]};
//添加规格卡功能
$scope.addTableRow=function () {
$scope.entity.specificationOptionList.push({});
}
//删除选项卡功能
$scope.removeTableRow=function (index) {
$scope.entity.specificationOptionList.splice(index,1);
}
--------点击删除按钮ng-click="removeTableRow($index)" ---------------------------------------------------------------
编写html的删除功能,ng-click="removeTableRow($index)" $index是ng-repeat="option in entity.specificationOptionList"循环的时候搞就可以拿到
<tbody>
<tr ng-repeat="option in entity.specificationOptionList">
<td>
<input ng-model="pojo.optionName" class="form-control" placeholder="规格选项">
</td>
<td>
<input ng-model="pojo.orders" class="form-control" placeholder="排序">
</td>
<td>
<button type="button" class="btn btn-default" title="删除" ng-click="removeTableRow($index)" ><i class="fa fa-trash-o"></i> 删除</button>
</td>
</tr>
</tbody>
----------------点击新增按钮 ng-click="addTableRow()"-----------------------------------------------------------------------------------
<!-- 规格选项 --> <div class="btn-group"> <button type="button" class="btn btn-default" title="新建" ng-click="addTableRow()" > <i class="fa fa-file-o" ></i> 新增规格选项 </button> </div>