【发布时间】:2013-10-23 03:40:40
【问题描述】:
我无法访问我的阵列控制器变量。例如,我有这个简单的应用程序:
App.js
App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.Router.map(function() {
this.route('hello');
});
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('hello');
}
});
App.HelloController = Ember.ArrayController.extend({
name: 'tom'
});
App.HelloRoute = Ember.Route.extend({
model: function() {
return this.store.find('hello');
}
});
App.Hello = DS.Model.extend({
title: DS.attr('string')
});
App.Hello.FIXTURES = [{
id: 1,
title: 'hello'
},{
id: 2,
title: 'hello'
}];
我的观点是:
<script type="text/x-handlebars" data-template-name="application">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="hello">
{{#each}}
{{title}} {{name}}
{{/each}}
</script>
当我保存这段代码时,页面只呈现“hello”“hello”,我期待“hello tom”“hello tom”。我做错了什么?
感谢您的帮助!
【问题讨论】:
标签: javascript ember.js controller ember-data