Is there any way I can alternate the loop execution in the below HTML? I have 2 div elements to print the properties Name and Age. If I run the below code, It is printing the name first and Age second. This yields output like below:
John
Jessie
Johanna
25
30
28
There should not be any change in HTML. One div is for Name and another one is for Age.I want output like below.
John
25
Jessie
30
Johanna
28
Below is the HTML for sample which I created.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<div id="name" ng-repeat="x in friends">
{{x.name}}
</div>
<div id="name" ng-repeat="x in friends">
{{x.age}}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.friends = [
{name:'John', age:25, gender:'boy'},
{name:'Jessie', age:30, gender:'girl'},
{name:'Johanna', age:28, gender:'boy'}
];
});
</script>
</body>
</html>