I am using the template at https://github.com/aspnet/JavaScriptServices/tree/dev/templates/Angular2Spa as a starting point for an Angular Universal SPA. It renders the Angular root component as follows:
@{
ViewData["Title"] = "Home Page";
}
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
I'd like for some of my Angular components to modify the contents of the HTML header (such as setting the title tag, or adding additional meta tags).
Keeping in mind that the template uses Razor to render the head portion of the page, are there any suggestions on how this can be achieved?
The only thing I am using Razor to handle is the asp-append-version tag helper, so moving all of the HTML rendering into an Angular component would be an option (provided I had a way to maintain the cache-busting somehow).
Thanks in advance!
You can set the document or window title using the Title service.
Sample implementation-
Working plunker from angular documentation available here