jeudi 28 mai 2020

EmberJS show router model in application.hbs

I am working with Ember.js, and I am trying to make my pages display the title of the page just below the navbar. To make this work I have tried to use model hook, and show it in the application.hbs file.

So far I have tried variations of this:

routes/contact.js

import Route from '@ember/routing/route';

export default class ContactRoute extends Route {
  model() {
    return 'Title of page';
  }
}

templates/application.hbs

<div>
  <NavBar />

  <div class="pageTitle">
    <h2>
      <p></p>
    </h2>
  </div>

  <div class="body">
    
  </div>
</div>

I've mostly tried to mess around with @model in application.hbs things like outlet.@model. But all of these attempts have resulted in empty titles or Template Compiler Errors. Does anyone have a solution for this? Preferably one that does not involve jquery?




Aucun commentaire:

Enregistrer un commentaire