Pio*_*Pio 2 javascript ember.js
我是Ember和JS的新手,到目前为止,我发现最广泛的教程是使用1.0.0 pre2,但在官方网站上有一个非常好的描述和一些1.0.0 pre4的例子.我开始使用它.我被困在路由,这是我的代码:
的index.html
<body>
Loaded.
<script type="text/x-handlebars" data-template-name="application">
In template displaying val: {{name}}
{{#linkTo "index"}}<img class="logo">{{/linkTo}}
<nav>
{{#linkTo "about"}}About{{/linkTo}}
{{#linkTo "favorites"}}Favorites{{/linkTo}}
</nav>
</script>
<script type="text/x-handlebars" data-template-name="about">
Here comes the about text: {{str}}
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
app.js
window.App = Ember.Application.create();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
})
App.ApplicationController = Ember.Controller.extend({
name: 'test'
})
App.AboutView = Ember.View.extend({
templateName: 'about'
})
App.AboutController = Ember.Controller.extend({
str: 'my string'
})
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
Run Code Online (Sandbox Code Playgroud)
它几乎与网站上的相同.我想要和想到的应该是,它会显示关于模板的内容,而只是将网址更新为/#/ about或/#/ favs.我在这里错过了什么?
| 归档时间: |
|
| 查看次数: |
3569 次 |
| 最近记录: |