I’m trying to use the new Router API (at commit 6a165ad), and I have some problems.
Given this router:
Router.map(function(match) {
match("/posts").to("posts", function(match) {
match("/new").to('new', function(match) {
match("/author").to('author');
});
});
});
I’m trying to transition to the new route.
Using new.index: this.transitionTo('new.index')
It works, but as you can see the route name is not really explicit (we don’t even know that it’s for a new post). It’s consequently not a viable solution.
Using posts.new: this.transitionTo('posts.new')
I hoped it works, but an error is thrown:
The route
posts.newwas not found.
I believed the transition to the index was made automatically, but it seems not.
Using customized route name:
Since the commit specified above, Ember allows custom route naming. As my previous attempt does not work, I tried to force the new route to be posts.new, but it still does not work (idem if it was foo.new).
It looks like its not possible to go to a customized route that has nested routes.
TL;DR
- I’d like to transition to the
newroute (and specifyingposts). How should it be done ? - Before the router v2.1, I had routes that has child without
to(i.e.match("/posts", function(match) { ... })), is it still working ? If so, what’s the name of its children ?
This was actually a bug in Ember. Because
indexis implicit, you should not need to explicitly provide it.The bug was fixed on master.
If you want to go to a route that has child routes, you should
transitionTothe specified name of the route, and Ember will automatically add theindexfor you.