app.component.ts
import { Component, Renderer2 } from '@angular/core';
import { Router, NavigationStart } from '@angular/router';
@Component({
selector: 'bb-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'bb';
previousUrl: string;
constructor(private renderer: Renderer2, private router: Router) {
this.router.events
.subscribe((event) => {
if (event instanceof NavigationStart) {
if (this.previousUrl) {
this.renderer.removeClass(document.body, this.previousUrl);
}
const currentUrlSlug = event.url.slice(1);
if (currentUrlSlug) {
this.renderer.addClass(document.body, currentUrlSlug);
} else {
this.renderer.addClass(document.body, "home");
}
this.previousUrl = currentUrlSlug;
}
});
}
}
i added a body class depending on the route. and depending on the body
class i ave to cane header color.
[image: Class.png] <about:invalid#zClosurez>
So how can i add css and where
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.