Feeling a bit stuck here, can't seem to figure out what I've missed.
I've managed to move up or down a row in a table, but I need the value of the cell in the first column to remain unchanged. Here's my code:
This is my HTML file:
<div ng-show="showStoppageTable" align="center" class="form-group-sm">
<table id="stoppageTable" class="table table-striped table-hover table-bordered table-xs ">
<thead>
<tr>
<th class="btn-info">serialNo</th>
<th class="btn-info">Stoppage Name</th>
<th class="btn-info">Description</th>
<th class="btn-info">Route order</th>
<th class="btn-info">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stoppage in StoppageData">
<td>{{ stoppage.orderId }}</td>
<td>{{ stoppage.stoppageName }}</td>
<td>{{ stoppage.description }}</td>
<td>
<div class="floating-buttons" align="center">
<button type="button" name="moveUpButton" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#moveUpModal" ng-click="r.ForMoveUp($index)" data-toggle="tooltip" data-placement="bottom" title="MoveUP"><i class="glyphicon glyphicon-triangle-top"></i></button>
<button type="button" name="moveDownButton" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#moveDownModal" ng-click="r.ForMoveDown($index)" data-toggle="tooltip" data-placement="top" title="MoveDown"><i class="glyphicon glyphicon-triangle-bottom"></i></button>
</div>
</td>
<td>
<div class="floating-buttons" align="center">
<button type="button" name="deleteStoppage" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteStoppage" ng-click="r.deleteStoppage(stoppage,$index)" data-toggle="tooltip" data-placement="bottom" title="DeleteStoppage"><i class="glyphicon glyphicon-trash"></i></button>
</div>
</td>
</tr>
</tbody>
</table>
And here's my ctrl.js
file:
vm.ForMoveUp = function (rowIndex) {
var StoppageData = $scope.StoppageData;
if (rowIndex > 0) {
var temp = StoppageData[rowIndex - 1];
StoppageData[rowIndex - 1] = StoppageData[rowIndex];
StoppageData[rowIndex] = temp;
$scope.rowIndex--;
}
}
vm.ForMoveDown = function (rowIndex) {
var StoppageData = $scope.StoppageData;
if (rowIndex < StoppageData.length - 1) {
var temp = StoppageData[rowIndex + 1];
StoppageData[rowIndex + 1] = StoppageData[rowIndex];
StoppageData[rowIndex] = temp;
}
}