Get list for each list item


#1

Hi everybody.

I have such API functions: /groups that gets list of existing groups and /group/{id}/items that gets all items in group by group’s id.

I want to show all groups:

	<ion-list>
	  <ion-item class="item-remove-animate" ng-repeat="g in groups" type="item-text-wrap">
		<h2>{{g.name}}</h2>
		<p>{{g.note}}</p>
		<ion-spinner></ion-spinner>
	  </ion-item>
	</ion-list>

and call API function /group/{id}/items for each group and show list of items instead of

how to do this?


#2

Create another state/view to show the details of your group and add an href or ui-sref attribute to your ion-item.

<ion-item href="#/groups/{{group.id}}" ng-repeat="g in groups" type="item-text-wrap">

Look at chats and chats-detail in the tabs ionic starter app.


#3

That’s not what I need. In this case user should click on the group to get items.

I want to get items for each group automatically, So, after initial page load I should see list of groups with spinner inside each of them, each group should make request on server to get its items and substitute spinner on items list after server response


#4

That would be quite inefficient: N+1 query performance problem.

Can’t you modify your API so that it includes items? That would require only one request and so be more efficient.