Angular Ng-repeat In Table
I've a question about angular 'ng-repeat'. I have a table, and in this table I will show the array values. Here is my js: var app = angular.module('plunker', []); app.controlle
Solution 1:
You have a lot of unnecessary things here. I chopped them out. You don't need trZeile at all. Also, this line was simply rebinding the same variable three times:
$scope.hadia = $scope.hadi[i].split(',');
Here's the working code: http://plnkr.co/edit/zz04pEDPst5Yo3thCXfy?p=preview
HTML
<table ng-controller="MainCtrl" style='border:2px solid black'>
<tr ng-repeat="row in hadia" style='border:2px solid black'>
<th scope="row">{{$index + 1}}</th>
<td ng-repeat="td in row track by $index" style='border:2px solid black'>
{{td}}
</td>
</tr>
</table>
Javascript
var app = angular.module('plunker', []);
app.controller('MainCtrl',function($scope){
$scope.hadia = [];
$scope.hadi = [
'Mercedes1,BMW1,Ford1,VW1,Renault1,Kia1',
'Mercedes2,BMW2,Ford2,VW2,Renault2,Kia2',
'Mercedes3,BMW3,Ford3,VW3,Renault3,Kia3'
]
for(var i = 0, j = $scope.hadi.length; i< j; i++){
$scope.hadia.push($scope.hadi[i].split(','));
}
});
Post a Comment for "Angular Ng-repeat In Table"