I have matrix(2D array) cells
in model, what I represent in a table.
<tr ng-repeat='row in cells track by $index'>
<td ng-repeat='cell in row track by $index'>
{{cell}}
</td>
</tr>
I want add a drop down buttons to resize length and width,
<select ng-model="length" >
<option ng-repeat="size in sizes" ng-click="setLength(size)">{{size}} </option>
</select>
but can't refresh ng-repeat
. For refresh page I use $scope.$apply()
after set new matrix in cells
$scope.cells = new Array($scope.width);
for (var i = 0; i < $scope.cells.length; i++) {
$scope.cells[i] = new Array($scope.length);
for (var j = 0; j < $scope.length; j++) {
$scope.cells[i][j] = 'cell';
}
}
$scope.$apply();
but it doesn't help. How to refresh ng-repeat
?
P.S. When user is changing size matrix, it should back to default values with new size.