Search code examples
ember.js-2

How application route getting triggered in emberjs


I am a newbie in emberjs and trying to understand an ongoing ember codebase. I see that application.js router and controller are getting executed by default in our project without mentioning it anywhere in router file. But ember cli is not generating application.js route by default also.

Why is it so ? Whats the real usage of application route and controller ? How is it getting executed ? Please share your thoughts or any useful doc links.

Tia


Solution

  • For the first part of the question this is taken straight from the docs:

    The application route is entered when your app first boots up. Like other routes, it will load a template with the same name (application in this case) by default. You should put your header, footer, and any other decorative content here. All other routes will render their templates into the application.hbstemplate's {{outlet}}.

    This route is part of every application, so you don't need to specify it in your app/router.js

    And as controllers:

    You only need to generate a Controller if you want to customize its properties or provide any actions. If you have no customizations, Ember will provide a Controller instance for you at run time.

    The Application template content Is always rendered so if you want something to appear on every page such as a navigation bar you place inside there.