I have an array in my app.js file, contents of which I would like to print sequentially in <td>
rows in my HTML table.
Below is my app.js file:
(function () {
var app = angular.module('TravelI', []);
var route = [{
source : [
"San Jose",
"San Francisco",
],
destination : [
"Wellington",
"Mumbai"
],
}];
app.controller('RouteController', function ($scope) {
$scope.product = route;
$scope.addRoute = function(s, d) {
};
});
})();
HTML code:
<div id="DisplayTable" ng-repeat="x in product">
<table style="width: 80%" align="center">
<tr>
<th>
From
</th>
<th>
To
</th>
</tr>
<tr>
<td>{{x.source[$index]}}</td>
<td>{{x.destination[$index]}}</td>
</tr>
</table>
</div>
Now I can only see the data correctly for the first element in the arrays. I want the display to be like this:
From To:
San Jose Wellington
San Francisco Mumbai
Any city that I append to the two arrays should be displayed sequentially in the table rows.
Currently I can only see the first element in both the arrays: