Search code examples
javascripttypescriptaureliapage-title

how to update other page title while active on other page?


Say, I'm in "Create Order" page, once I placed an order and saved it, "Jobs [0]" page will increment by 1 and display as "Jobs 1". Something like that.

I already saw some answers here at SO but it utilizes the activate method in which the user have to be in the page before it'll change the page title. Please advise

Below is my sidebar

sidebar


Solution

  • Assume your sidebar menu was implemented like this.

    <a 
      repeat.for="row of router.navigation"
      href.bind="row.href"
      class.bind="row.isActive ? 'active' : ''"
    >${row.title}</a>
    

    You don't need to update the route's title itself.

    You are tracking the total job count in your front-end code anyway, just show that variable after title of route "jobs".

    <a 
      repeat.for="row of router.navigation"
      href.bind="row.href"
      class.bind="row.isActive ? 'active' : ''"
    >${row.title} <span if.bind="row.config.name == 'jobs'">[${jobCount}]</span></a>