Я новичок в java script, поэтому я должен извиниться, если это кажется простым.
Как я могу редактировать таблицы строк в Smart-Table с помощью Angularjs? Похоже, что нет учебника по новому Smart-Table. Я хотел бы создать простую форму для пользователей, чтобы ввести часы, открытые для определенного места.
Я создал кнопки, которые могут добавлять и удалять строки в таблице, но когда я добавляю contenteditable="true" ни одно из изменений не сохраняется при обновлении объекта. Я понимаю, что contenteditable - это определенные параметры html5, независимые от смарт-таблицы, но я не понимаю, как еще я могу обновить данные или как я могу получить обновленные данные.
Данные извлекаются из контроллера angularjs через маршруты mean.js.
<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>
Внутри javascript:
$scope.removeOpenHour = function removeOpenHour(row) {
var index = $scope.place.openHours.indexOf(row);
if (index !== -1) {
$scope.rowCollection.splice(index, 1);
}
}
$scope.addOpenHour = function addOpenHour() {
$scope.place.openHours.push(
{
day: 'Monday',
open: 540,
close: 1080
});
};