[英]Ember route not displaying template content
I am new to Ember and JS, so far the most extensive tutorials I found were using 1.0.0 pre2, but on the official site there is a very nice description and some examples of 1.0.0 pre4. 我是Ember和JS的新手,到目前为止,我发现最广泛的教程是使用1.0.0 pre2,但是在官方站点上有一个非常不错的描述以及1.0.0 pre4的一些示例。 I started to use that.
我开始使用它。 I am stuck at routing, here is my code:
我被困在路由中,这是我的代码:
index.html 的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>
app.js 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" });
});
It's almost identical to the one from the site. 它几乎与该站点中的相同。 What I want and think should happen, is that it will display the content of about template, but instead it just updates the url's to /#/about or /#/favs .
我想要并认为应该发生的事情是,它将显示about模板的内容,而只是将url更新为/#/ about或/#/ favs。 What am I missing here?
我在这里想念什么?
What I want and think should happen, is that it will display the content of about template, but instead it just updates the url's to /#/about or /#/favs .
我想要并认为应该发生的事情是,它将显示about模板的内容,而只是将url更新为/#/ about或/#/ favs。 What am I missing here?
我在这里想念什么?
Your application template does not have an {{outlet}}
. 您的应用程序模板没有
{{outlet}}
。 With that in place it will work as expected. 有了它,它将按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.