1

{{.}}是否可以从内部引用隐式迭代器的值Ember.View

例如

查看模板

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

查看代码

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
    }
});
4

1 回答 1

4

我不知道我是否理解得很好,但你可以做类似的事情

{{#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'));
  }
});
于 2012-10-02T19:27:55.137 回答