Ember.js emberjs itemcontroller属性范围

Ember.js emberjs itemcontroller属性范围,ember.js,Ember.js,我需要一个在emberJS中使用itemcontroller的解释 我创建了一个把手模板,如下所示: {{#each thing in controller itemController="itemController"}} {{view "testview" contentBinding="thing"}} {{/each}} testview创建了一个html表,在testview中,我在each循环中使用了第二个视图,该循环创建了几个tr: {{each item in view

我需要一个在emberJS中使用itemcontroller的解释

我创建了一个把手模板,如下所示:

{{#each thing in controller itemController="itemController"}}

  {{view "testview" contentBinding="thing"}}

{{/each}}
testview创建了一个html表,在testview中,我在each循环中使用了第二个视图,该循环创建了几个tr:

{{each item in view.content.thing}}

  {{view 'trview' contentBinding="item"}}

{{/each}}
除此之外,我还向itemController添加了一个属性“listOfProperties”(Ember.a())

我使用trview的click函数向itemController的“listOfProperties”数组添加一个值


在这里,我收到一个错误:如果我单击一个tr,该值将添加到每个itemControllers“listOfProperties”数组,而不仅仅是一个“things”itemController。

我猜,因为您没有包括您的item controller,但很可能您遇到了引用问题。数组是引用,因此在项控制器的实例之间共享

App.ItemController = Em.ObjectController.extend({
  setup: function(){
    this.set('listOfProperties', []);
  }.on('init'),
  listOfProperties: null,
});