问题描述
我已经查看了文档,看不到我在做什么错。
I've gone over the docs and I can't see what I'm doing wrong.
Router.map
App.Router.map(function(){
this.resource('users', function(){
this.resource('user', { path: ':user_id' });
this.resource('add');
});
});
车把
<script type="text/x-handlebars" id="users/add">
<h3>Add User</h3>
</script>
我的链接指向正确的URL:
{{#link-to'add'}}添加用户{{/ link-to}}
I get the proper URL with my link-to:{{#link-to 'add'}}Add User{{/link-to}}
但是我的车把模板的内容对于用户/从未显示?
However the contents of my handlebar template for users/add never show?
这是我的路线
App.UsersRoute = Ember.Route.extend({
model: function(){
console.log("Users route triggered");
return App.Users;
}
});
App.UserRoute = Ember.Route.extend({
model: function(params){
return App.Users.findBy('id', params.user_id);
}
});
App.UserAddRoute = App.UserRoute.extend({
renderTemplate: function(){
console.log("Users Add Route triggered");
this.render('users/add');
}
});
这是我的jsbin:
Here's my jsbin: http://jsbin.com/denap/3/edit?html,js,output
推荐答案
您的代码有一些错误,因为车把
模板块由 data-template-标识名称
,而不是 id
。也可以将 add
声明为嵌套的路由
,而不是嵌套的资源
-在此处查看您更新过的(并且正在工作的)jsbin:
your code had a few errors, as the handlebars
template blocks are identified by data-template-name
rather than by id
. also you could declare add
as a nested route
than a nested resource
- see your updated (& working) jsbin here: http://jsbin.com/yuzedacu/1/edit
这篇关于灰烬嵌套路线不会显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!