I'm still getting the hang of Java Script, so please bear with me if this question is a bit basic.
Does anyone know how to edit rows in tables using Smart-Table with AngularJS? I can't seem to find any tutorials that match the new version of Smart-Table. My goal is to create a simple form for users to input the opening hours for a specific place.
I've managed to add and remove rows from the table using buttons, but when I try to make the content editable by adding "contenteditable=true", none of the changes are saved when I update the object. I realize that "contenteditable" is an HTML5 attribute and not directly related to Smart-Table, but I'm not sure how else to update the data or retrieve the updated information.
The data is fetched from the AngularJS controller through the mean.js routes.
<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>
In the JavaScript file:
$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
});
};