How do I display a component only on the home screen?

0

Within application.hbs I have a component called jus-hero :

<header class="bg-leaf">
  {{jus-hero}}
</header>
<main class="l-main">
  {{outlet}}
</main>

How to render this component only on index page? This setting is in the file app/components/jus-hero.js ?

    
asked by anonymous 21.02.2017 / 17:54

2 answers

0

Simple solution after a few searches on GitHub.

Just install ember install ember-truth-helpers and do the check with the name of the route:

{{#if (eq currentRouteName 'index')}}
  {{jus-hero}}
{{/if}}

I hope to be helping others with the same doubt:]

    
21.02.2017 / 20:12
1

You can define your home as some specific route, other than the application route. That way, displaying the component in question just in it.

Example:

In your router.js file

Router.map(function() {
  this.route('home', {
    path: '/'
  });
});

And in your home.hbs (home route template)

{{!-- home.hbs --}}
<header class="bg-leaf">
  {{jus-hero}}
</header>

In application.hbs keeping only

{{!-- application.hbs --}}

<main class="l-main">
  {{outlet}}
</main>
    
27.03.2018 / 19:00