Need to make a ng-repeat
within another ng-repeat
, to access each array
and print the values:
Html
:
<div ng-app="app">
<div ng-controller="ctrl">
<div ng-repeat="array in arrays">
<div ng-repeat="v in array">
{{v.name}}
</div>
</div>
</div>
</div>
Angular
:
var app = angular.module('app', []);
app.controller('ctrl', ['$scope', function($scope)
{
$scope.arrays = [
[{'name':'a1'}, {'name':'a2'}],
[{'name':'a3'}, {'name':'a4'}]
];
}]);
The arrays
would be the main and array
each internal item.
Example:
var app = angular.module('app', []);
app.controller('ctrl', ['$scope', function($scope)
{
$scope.arrays = [
[{'name':'a1'}, {'name':'a2'}],
[{'name':'a3'}, {'name':'a4'}]
];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div ng-app="app">
<div ng-controller="ctrl">
<div ng-repeat="array in arrays">
<div ng-repeat="v in array">
{{v.name}}
</div>
</div>
</div>
</div>
References:
is with angular what you need?
– novic
Enter the code of your
ng-repeat
. You’ll have to do 2 to go around.– Sorack