ember.js 1.0.pre
我试图弄清楚为什么下面的小提琴在工作时不起作用0.9.5
。
版本 0.9.5(工作)
版本 1.0.pre(不工作)
我知道这handlebars.js
不包含在最新版本中ember.js
,我必须自己包含它。
这是我正在使用的代码:
<script type="text/x-handlebars">
{{#view Ember.Button target="Welcome.booksController" action="loadBooks"}}
Load Books
{{/view}}
{{#collection contentBinding="Welcome.booksController"}}
<i>Genre: {{content.genre}}</i>
{{/collection}}
</script>
Welcome = Ember.Application.create();
Welcome.Book = Ember.Object.extend({
title: '',
author: '',
genre: ''
});
var data = [ { "title": "Ready Player One", "author": "Ernest Cline", "genre": "Science Fiction" }, { "title": "Starship Troopers", "author": "Robert Heinlein", "genre": "Science Fiction" }, { "title": "Delivering Happiness", "author": "Tony Hsieh", "genre": "Business" } ];
Welcome.booksController = Ember.ArrayController.create({
content: [],
loadBooks: function(){
var self = this;
data.forEach(function(item){
self.pushObject(Welcome.Book.create(item));
});
}
});
来源是:http ://www.andymatthews.net/read/2012/03/07/Getting-Started-With-EmberJS