I am trying to set the title, however in this code below it works in one place and doesnt in other place. I want to get the product name and set the title. Is there any other way to do it?
activate(params: any, route, navigationInstruction) {
//route.navModel.router.title="test"; //works here
this.api.pull<Product>([params.id]).then(items => {
items.forEach(item=>
{
if(item.id == params.id)
route.navModel.router.title = item.name //does NOT work here
});
});
}
Try to return promise from api call, looks like page title is set after activate
hook, so you have to set route.navModel.router.title
before activate
hook finishes execution
activate(params: any, route, navigationInstruction) {
//route.navModel.router.title="test"; //works here
return this.api.pull<Product>([params.id]).then(items => {
items.forEach(item=>
{
if(item.id == params.id)
route.navModel.router.title = item.name //does NOT work here
});
});
}