HI, I’m starting out with ember and so far so good, i’ve been able to follow couple examples and set up basic applications. From what i’ve read, i don’t understand the purpose of the ApplicationRoute and the difference with the IndexRout, when to use which one?
I get the basics of the index as far as getting the index.html running and setting up a starting page. Not quite there yet with the application. I would appreciate some one getting deeper into the topic.
ApplicationRoute is the top most route of your application. Its the first thing that’s hit before your code redirects the user to someone else. You could put a bunch of HTML into the application template and your app will effectively work like a widget. Being ApplicationRoute is the top of your route tree, it can be used to handle actions that apply to many aspects of your application. For example, if you have search operation that can be triggered from many places in your app, then you could put your search action into the ApplicationRoute and it would handle the search function whenever its triggered from anywhere in your app. You can learn more about actions in the Handling User Interaction with Actions guide. ( That guide is written about handling actions in controllers, but it applies same way to routes. Architecturally, routes are above controllers, so whatever is not handled in the controller will bubble up to the route. )
IndexRoute is a freebee that you get with every resource. Resources can have other resources and routes under them, IndexRoute is a route that’s automatically added to a resource when you add a resource. IndexRoute is nested into the resource that you created, so architecturally, its a child of the resource. Its useful when you want to create a page that handles default action for the route. For example, let’s say you have a search route.
Thanks for the response, im letting it sink, but your answer really provided help. So for example an authentication componente could sit in the application controller / route?
Here is an example of another way to do this https://github.com/mixonic/grimvisage checkout how the ApplicationRoute is used. The difference is that Sing In and Sign Out are treated as separate routes and controllers.