Ember.js View get value of implicit iterator in context
-
12-12-2019 - |
Pregunta
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
}
});
Solución
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'));
}
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow