I want to bind html table row by specific count times using angularJS binding like below:
<table>
<tr ng-repeat="x in 5">
<td>abc</td>
</tr>
</table>
If anybody have solution, please reply as possible. Thanks
I want to bind html table row by specific count times using angularJS binding like below:
<table>
<tr ng-repeat="x in 5">
<td>abc</td>
</tr>
</table>
If anybody have solution, please reply as possible. Thanks
You can use constructor like this (no code in js required) :
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<table>
<tr ng-repeat="n in [].constructor(10) track by $index">
<td>abc</td>
</tr>
</table>
</div>
</body>
</html>
Pass the number to a function and generate the array according to it.
DEMO
var app = angular.module('myapp',[]);
app.controller('ctrl',function($scope){
$scope.getNumber = function(num) {
return new Array(num);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myapp">
<div ng-controller="ctrl">
<table>
<tr ng-repeat="x in getNumber(5) track by $index">
<td>abc</td>
</tr>
</table>
</div>
</div>
The following code will work for you:
Number of visible Values: {{(data|filter:query).length}}
Total number of Values: {{data.length}}
summary
{{data.length}}
- prints total number of Values
{{(data|filter:query).length}}
- prints filtered number of Values
Sol 1
<table>
<tr ng-repeat="x in [1,2,3,4,5]">
<td>abc</td>
</tr>
</table>
Sol 2
or create blank array in back end and use here like in laravel
$scope.newarr = new Array(5);
IN angular
<table>
<tr ng-repeat="x in newarr track by $index">
<td>abc</td>
</tr>
</table>