admin管理员组文章数量:1421994
I understand that routes are used to map URLs to templates, but apparently you could either define routes with this.route or this.resource
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
App.Router.map(function() {
this.resource('posts', { path: '/posts' }, function() {
this.route('new');
});
});
Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
I understand that routes are used to map URLs to templates, but apparently you could either define routes with this.route or this.resource
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
App.Router.map(function() {
this.resource('posts', { path: '/posts' }, function() {
this.route('new');
});
});
Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
Share Improve this question edited Apr 2, 2013 at 1:46 Marco Petersen asked Apr 2, 2013 at 1:23 Marco PetersenMarco Petersen 3313 silver badges14 bronze badges2 Answers
Reset to default 8Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
That's the basic idea.
- resource = parent (usually a noun)
- route = child (often a verb)
Also keep in mind that the router always points to a current route. It cannot transition to a resource. Behind the scenes ember automatically generates an 'index' route underneath every resource, so even if you define something like this:
App.Router.map(function() {
this.resource("about", { path: "/about" });
});
you end up with this:
App.Router.map(function() {
this.resource('about', { path: '/about' }, function() {
this.route('index');
});
});
this is being depreciated in ember 3.x. there is no more this.resource()
本文标签: javascriptWhat39s the difference between thisroute() and thisresource()Stack Overflow
版权声明:本文标题:javascript - What's the difference between this.route() and this.resource()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745344504a2654415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论