Question

Is it possible to reference the value of the implicit iterator {{.}} from inside an Ember.View?

e.g.

View Template

{{#each simple_old_array_of_numbers}}
    {{view App.Subview}}
{{/each}}

View Code

App.Subview = Em.View.extend({
    template_name: 'subview_template',
    didInsertElement: function() {
        //do some logic based on the implicit iterator
        //have tried this.get('.'), but that didn't work
    }
});
Was it helpful?

Solution

I don't know if I understand well, but you can do something like

{{#each item in simple_old_array_of_numbers}}
  {{view App.Subview itemBinding="item"}}
{{/each}}

App.Subview = Em.View.extend({
  template_name: 'subview_template',
  item: null,
  didInsertElement: function() {
    console.log(this.get('item'));
  }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top