我正在关注"emberjs.com"的一个例子,这个例子并不太顺利.我的应用程序中有一个"GuestController"和"GuestView".我想使用"{{#view}}&{{#each}}从"GuestView"输出一个名为"guests"的对象.我正在关注这个在线示例:
http://emberjs.com/documentation/#toc_displaying-a-list-of-items
小提琴:http://jsfiddle.net/exciter/MjA5A/8/
这是代码:
APP代码:
$(function(){
App = Ember.Application.create({
ready: function(){
//alert("APP INIT");
}
});
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
templateName: "application",
classNames: ['']
});
App.GuestController = Ember.Controller.extend();
App.GuestView = Ember.View.extend({
guests: [{name:"The Doctor" },
{name:"The Scientist" },
{name:"The Maestro"}]
});
App.initialize();
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<script type="text/x-handlebars" data-template-name="application">
{{#each App.GuestController}}
{{#view App.GuestView}}
{{guests}}
{{/view}}
{{/each}}
</script>
Run Code Online (Sandbox Code Playgroud)