我是java脚本的新手,所以如果这看起来很基本,我必须道歉.
如何使用Angularjs在Smart-Table中编辑行表?新智能表似乎没有教程.我想创建一个简单的表单,供用户输入特定地点的营业时间.
我创建了可以在表上添加和删除行的按钮,但是当我添加contenteditable ="true"时,更新对象时没有任何更改持久存在.我知道contenteditable是一个独立于smart-table的特定html5参数,但我不明白我如何更新数据或如何检索更新的数据.
通过mean.js路径从angularjs控制器检索数据.
<div class="controls">
<table st-table="place.openHours" class="table table-striped">
<thead>
<tr>
<th>Day</th>
<th>Opening Time</th>
<th>Closing Time</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in place.openHours" contenteditable="true" >
<td>{{row.day}}</td>
<td>{{row.open}}</td>
<td>{{row.close}}</td>
<button type="button" ng-click="removeOpenHour(row)" class="btn btn-sm btn-danger">
<i class="glyphicon glyphicon-remove-circle">
</i>
</button>
</tr>
</tbody>
</table>
<button type="button" ng-click="addOpenHour(row)" class="btn btn-sm btn-success">
<i class="glyphicon glyphicon-plus">
</i> Add new Row
</button>
</div>
Run Code Online (Sandbox Code Playgroud)
在javascript里面:
$scope.removeOpenHour = function removeOpenHour(row) {
var index = $scope.place.openHours.indexOf(row);
if (index !== -1) {
$scope.rowCollection.splice(index, 1);
}
}
$scope.addOpenHour = …Run Code Online (Sandbox Code Playgroud)