Jav*_*tar 5 javascript ember.js
我没有找到任何关于开始使用Ember.js的好文档.请帮助我,这是一个简单的例子我试过http://emberjs.com/documentation/但屏幕上没有显示任何内容.
Error: MyApp is not defined
Run Code Online (Sandbox Code Playgroud)
Javascript:app.js
MyApp.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
// Tell Ember that this computed property depends on firstName
// and lastName
}.property('firstName', 'lastName')
});
Run Code Online (Sandbox Code Playgroud)
HTML
<p>
<script type="text/x-handlebars">
The President of the United States is {{MyApp.president.fullName}}.
</script>
</p>
Run Code Online (Sandbox Code Playgroud)
我包含了入门套件中的所有JS文件.
小智 6
您忘了定义MyApp,它必须是Ember.Application的一个实例:
var MyApp = Ember.Application.create({});
Run Code Online (Sandbox Code Playgroud)
这是我几周前发现的一个非常全面的教程,可能对你的学习目的有用:http://www.appliness.com/flame-on-a-beginners-guide-to-ember-js/