Base solution for your next web application
Open Closed

Dynamic Page Title #4600


User avatar
0
ogrodski created

I'm using the .NET Core with Angular version and I would like to know how to dynamically update the page title to match the current page.

It looks like the <title> element is hard coded to the project name in the index.html file. This means every pages has the same title. Can we dynamically set the title based on the selected menu item or page?

Thanks,

Al


3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    in root-routing.module.ts you can change the title [attachment=0:2x1o2iwy]Screenshot_2.jpg[/attachment:2x1o2iwy]

  • User Avatar
    0
    ogrodski created

    Thanks for your response. Sorry for the delay, but I just saw your response.

    Your suggestion works okay to display the url in the page title, but sometimes it shows "undefined" when you navigate between different pages.

    What I would like to do is get the Menu Item name from the localization files to display in the page title. Can someone advise how I could get the menu item name from the localization xml file?

    <text name="OrganizationUnits">Organization Units</text>

    For example, I would like Organizational Units to appear in the page title.

    Thanks,

    Al

  • User Avatar
    0
    ismcagdas created
    Support Team

    @ogrodski,

    Another alternative;

    You can add a title property into your App component base and set the title using jQuery in app component base's ngAfterViewInit event.