我有一个Ember.Select视图,它有一个到 ArrayController 的 contentBinding。当我在 ArrayController 上设置 itemController 时,它突然抛出这个错误: Uncaught TypeError: Cannot call method 'child' of null
这是一个极简主义的例子:
<script type="text/x-handlebars" data-template-name="application">
{{view Ember.Select viewName="select"
contentBinding="App.monstersController"
optionLabelPath="content.name"
optionValuePath="content.id"
prompt="Pick a monster:"
selectionBinding="App.stateController.selectedMonster"}}
</script>
和javascript:
window.App = Em.Application.create();
App.ApplicationController = Em.Controller.extend({});
App.ApplicationView = Em.View.extend({
templateName: 'application'
});
App.data = [{
id: 1,
name: "Grog",
strength: 10,
species: "Troll"
}, {
id: 2,
name: "Ognog",
strength: 8,
species: "Goblin"
}, {
id: 3,
name: "Fred",
strength: 3,
species: "Human"
}];
App.stateController = Em.Controller.create({
selectedMonster: null
});
App.MonsterController = Em.ObjectController.extend({
name: function() {
return "Controller Modified " + this.get('name');
}.property('content.name')
});
App.MonstersController = Em.ArrayController.extend({
content: App.data/*,
itemController: "monster"*/
});
App.monstersController = App.MonstersController.create({});
这是一个小提琴,演示了问题:http: //jsfiddle.net/Malkyne/AkHhF/
有谁知道这里发生了什么,或者我该如何解决?