Unable to set dynamic navigation bar items in ember

I have a navbar component that I placed in application.hbs so that it is always visible. But I want to change the title of the navigation bar on every page I visit (let's say I'm on the index page, she should say "Home", if I'm on the profile page, this should say profile, etc.). Now all that happens is the navbar header always remains “Home” for the whole page. This is because navbar gets the displayed onlu when the page loads in the browser, and after that it does not change according to the page.

application.hbs

{{top-navbar dp_url=model.profile.dp_url first_name=model.profile.first_name title=title}}

{{outlet}}

Here I calculate the value of the title depending on which page the user is on.

application.js (controller)

if (currentPage === "" || currentPage === "#"){
      currentState.set('title',"Home")
 }
else if(currentPage === "Userprofile"){
      console.log('myStudio');
      currentState.set('title',"UserProfile");
}

currentpage url , title navbar.

top-navbar , , .

Ember.Evented, .

+4
1

, Ember.js Ember-data , currentState 2.1, , , Ember .

(, , ) , :

  • , (, navbar-data).
  • , , (, store.createRecord('navbar-data', { id: 1, title: "index" })).
  • ( ).
  • , , store.peekRecord('navbar-data', 1) , .

, , , record.save().

0

All Articles