My question involves the new routing mechanism which was integrated into the master ember.js branch not too long ago.
In the following code block:
App.Router.map(function(match) {
match("/comments").to("commentsIndex");
});
The ember router now recognizes the comments url, and maps the route handler to commentsIndexRoute via the first parameter of the “to” method (in this case “commentsIndex”). From here you can choose to use the default mappings to the views/templates/controller, or perhaps override them.
However in the following nested route:
App.Router.map(function(match) {
match("/posts").to("posts", function(match) {
match("/").to("postsIndex");
match("/:post_id").to("postShow");
});
});
I am now unsure what the role is of the first parameter for “to” method in the first match. In other words, I am unsure of the role of the capitalized parameter below:
match("/posts").to("POSTS", function(match) {
what does that parameter do exactly?
It seems that this is now the recommended way of embedding “views”.
From the new Ember documentation:
http://emberjs.com/guides/routing/defining-your-routes/
So, .to(“POSTS”) sets the context to load the following views.