Search code examples
angulardirectiveangular5meta

Header and Footer in Angular 5


I am creating my website in angular 5

I have homepage, stores and categories as pages in my site

Initially I decided to keep header and footer as global across the website.

I mean to create a header and footer components and use them as directives

<app-header></app-header>
<app-homepage></app-homepage>
<app-header></app-header>

<app-header></app-header>
<app-stores></app-stores>
<app-header></app-header>

<app-header></app-header>
<app-categories></app-categories>
<app-header></app-header>

I am trying to use the meta information of the page, like page title, meta-keywords from my database.

For the homepage it is possible.

For stores and categories I am little confused how can I use the page title, meta-keywords.

For example:

`<html>
<title>{{ homepage.title }}</title>
<meta keywords = {{ homepage.meta_keywords }}>
</html>`

The above is possible for homepage.

But for Stores and Categories it will change according to page.

Need a solution on how I can change the title and meta keywords according to page

Like for stores :

`<html>
<title>{{ storepage.title }}</title>
<meta keywords = {{ storepage.meta_keywords }}>
</html>`

Solution

  • This is what I found working :

    https://github.com/angular/angular-cli/wiki/stories-universal-rendering