0

In a template:

{{#each displayVideos}}   

Index:   {{_view.contentIndex}}

{{/each}}

It will display all item in model.

But I want to display only some item depend on index(ex: Display item if index%2==0).

Any idea about it? Thanks

hoangmeo325
  • 450
  • 2
  • 10
  • 18

2 Answers2

2

Create a computed property in your controller, that will only return every second row, and iterate over that instead...

Something like:

App.MyController = Ember.ObjectController.extend({
    everySecondRow: function() {
        //code to only return every second row
    }.property('model')
});

Then in your template:

{{#each controller.everySecondRow}} ... {{/each}}
Joachim H. Skeie
  • 1,893
  • 17
  • 27
0

We can use helpers also. Here is an example.

yuva 443
  • 163
  • 1
  • 2
  • 11