codelearner codelearner - 5 months ago 7
JSON Question

How to write two ng-repeat by mixing the values?

i have 2 json ,

$scope.start_date=[{'01/02/2016'},{'05/05/2014'},{'08/02/2015'},{'04/08/2016'}]
$scope.end_date=[{'01/02/2016'},{'05/05/2014'},{'08/02/2015'},{'04/08/2016'}]


i have to display first start_date and first end_date , second start_date and second end_date using ng-repeat.Is it possible to display like this using ng-repeat using anguarjs. can anyone please help me

Answer

I think you're looking for something like below. There are a few ways to do it. ng-repeat exposes $index which you can use to display an item in the other array, assuming both arrays have the same number of items.

<ul>
  <li ng-repeat="date in start_date">Start: {{date}}, End: {{end_date[$index]}}</li>
</ul>

And you should make those arrays:

$scope.start_date=['01/02/2016','05/05/2014','08/02/2015','04/08/2016'];
$scope.end_date=['01/02/2016','05/05/2014','08/02/2015','04/08/2016'];