1

I new to AngularJS and wish to access two arrays under ng-repeat. This is my code:

<tr ng-repreat="find in findOptions">
<td>find.first</td>
<td>find.second</td>
<td>{{ search[{{$index}}].third }}</td>
</tr>

search is another array that I want to access here

2 Answers 2

3

You can't have iterpolation inside a intepolation again, basically you could access scope variable directly inside it.

You could simply directly use $index to access array.

search[$index].third
Sign up to request clarification or add additional context in comments.

Comments

1

Created JSFiddle Demonstration - https://jsfiddle.net/qtksp1kj/

Hope this will help!

<body ng-app="SampleApp">
  <table ng-controller="fcController" border="1px">
    <thead>
      <tr>
        <td>Name</td>
        <td>Address</td>
        <td>LandMark</td>
      </tr>
    </thead>
    <tbody ng-repeat="element  in myArray">
      <tr>
        <td>{{element.name}}</td>
        <td>{{element.address}}</td>
        <td>{{myArray1[$index].landMark}}</td>
      </tr>
    </tbody>
  </table>
</body>


var sampleApp = angular.module("SampleApp", []);
sampleApp.controller('fcController', function($scope) {
  $scope.myArray = [{
    'name': 'Name1',
    'address': 'H-1 China Town'
  }, {
    'name': 'Name2',
    'address': 'H-2 China Town'
  }];

  $scope.myArray1 = [{
    'landMark': 'Near Dominos'
  }, {
    'landMark': 'Near Airport'
  }];
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.