# Angular JS + elasticsearch Query - Response

**URL:** <https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966>\
**Category:** Elasticsearch\
**Created:** [March 10, 2016, 1:01am UTC](https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966 "2016-03-10T01:01:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_rai](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vivek\_rai](https://discuss.elastic.co/u/Vivek_rai)\
**Post date:** [March 10, 2016, 1:01am UTC](https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966/1 "2016-03-10T01:01:21Z")

</div>

I have the following program which is working fine , the issue is when i introduce ng-repeat tag. The results are not getting printed ...

I'm sorry to be verbose but wanted to provide all details to see if iam missing something overhere.

Code

 Elasticsearch + Angular Example 

# Angular + Elasticsearch

```
<!-- if there is an error, display its message -->
<div ng-if="error" class="alert alert-danger" role="alert">{{error.message}}</div>

<!-- if clusterState is available, display it as formatted json -->
<div ng-if="clusterState" class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">Cluster State</h3>
  </div>
  <div class="panel-body">
    <pre>{{clusterState | json}}</pre>
  </div>
</div>
<div class="container-fluid">
<div class="row-fluid">
	<span class="span3">
		<input class="input-block-level" ng-model="queryTerm" type="text">
	</span>&nbsp;
	<button ng-click="search()" class="btn" type="button">Search</button>
</div>
<div ng-if="results" class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">Results</h3>
  </div>
                  <table>
				  <thead>
                 <tr>
                    <th>Name</th>
                    <th>Marks</th>
                 </tr>
				 </thead>
				 <tbody>
                 <!---- This is not working -->
				 <tr ng-repeat = "subject in results._source.entityAttributes">
                    <td>{{ subject.legacyEntityAttributeName }}</td>
                    <td>{{ subject.legacydataType }}</td>
                 </tr>
				</tbody>		
              </table>    
		<div class="panel-body">
				<!-- This prints the Jason beautifully see output--> 
				<pre>{{results | json}}</pre>
			</div>
		</div>
    </div>

```

 ============

output

Results  
NameMarks [  
{  
"\_index": "legacytables",  
"\_type": "existingtables",  
"\_id": "AVNC54hNO04QfeJDGYBX",  
"\_score": 3.9704144,  
"\_source": {  
"dbEntityName": "TAAGENT\_REMARK",  
"otherEntityName": [  
"pc\_account",  
"pc\_note",  
""  
],  
"entityAttributes": [  
{  
"legacyEntityAttributeName": "HOUSEHOLD\_NUM",  
"legacydataType": "CHAR",  
"legacydatalength": "10.0",  
"legacydataDefinition": "A unique system generated number which is used to identify a specific household.",  
"legacydataClassification": "",  
"dataTeamReviewComments": "",  
"functionalTeamReviewComments": "",  
"xmlTag": "",  
"mappingLastUpdatedDate": "",  
"mappingLastUpdatedBy": "",  
"gwentityAttributeName": "AccountNumber",  
"gwtableName": "pc\_account",  
"gwdataType": "Varchar(255)",  
"gwdatalength": "Varchar(255)",  
"mappedBy": "",  
"mappedDate": "",  
"team": "",  
"gwdataDefinition": "The account number of this account. ",  
"gwdataClassification": ""  
},////Ignoring others for brevity  
]  
}  
}  
]

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [March 10, 2016, 1:39am UTC](https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966/2 "2016-03-10T01:39:42Z")

</div>

The JSON output shows an outer array of all the results and within each result there is array, `_source.entityAttributes`. Yet you only have one `ng-repeat` loop.

I think you need an outer `ng-repeat` loop to loop over all the results and an inner `ng-repeat` loop to loop over `_source.entityAttributes` within each result.

---

<div class="post-metadata">

**Author:** ![Vivek\_rai](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vivek\_rai](https://discuss.elastic.co/u/Vivek_rai)\
**Post date:** [March 10, 2016, 2:34am UTC](https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966/4 "2016-03-10T02:34:16Z")

</div>

Iam doing that only please see my code  
response object is set to resp.hits.hits and then ng repeat iam trying to get from \_source.entityAttributes only.

I'm skipping the first loop by setting the response object.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/angular-js-elasticsearch-query-response/43966/5 "2017-07-05T23:09:44Z")

</div>


