The task is to change the background-color depending on the routes. I have to show different color for UpcomingComponent and for the others route the background-color will remain the same.
I am trying to set value in STYLES in for /deep/ .classname for background-color dynamically.
Below is the code
@Component({
selector: 'app-upcoming',
templateUrl: './upcoming.component.html',
// styleUrls: ['./upcoming.component.css'],
styles: [`
/deep/ .root {
background-color: color;
}`]
})
export class UpcomingComponent implements OnInit {
color: string;
ngOnInit() {
this.bodyBackgroundImage();
}
bodyBackgroundImage() {
if (window.location.pathname === '/upcoming'){
console.log("Here i am");
this.color = 'purple';
}
}
}