new to Angular so please bear with me (or just point me to the appropriate docs article if this is just that obvious)
Basically, the structure of my site (for all of the pages) is this:
navigation (home, about, resources, contact)
header-div
content
footer
I want it so that any of the links you click will change the contents of the header-div; for now I'll start with changing the background color. For example, the home page's header is blue, about is red, resources is green, contact is yellow.
What I started doing but got stuck with was directly manipulating the style by using a method and click listener on the links
How would I got about attaching a class to the div, based on the link that's been clicked?
This is my app.component.ts
import { Component } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
@Component({
selector: 'app-root',
template: `
<div class="app-nav">
<nav class="set-margin">
<ul>
<li><a routerLink="/" routerLinkActive="active" (click)="showStyle = !showStyle">Home</a></li>
<li><a routerLink="/about" routerLinkActive="active">About</a></li>
<li><a routerLink="/resources" routerLinkActive="active">Resources</a></li>
<li><a routerLink="/contact" routerLinkActive="active">Contact</a></li>
</ul>
</nav>
</div>
<div [ngStyle]="getHeaderStyle()" class="app-mainheader">
<div class="app-mainheader__content set-margin">
this is the header for the
</div>
</div>
<router-outlet></router-outlet>
<app-footer></app-footer>
`,
styleUrls: ['./app.component.scss']
})
export class AppComponent {
showStyle = false;
getHeaderStyle() {
// ???
}
}