Background color angular

Asked

Viewed 239 times

0

How do, in angular 7, a background-color of the body different from the page I’m displaying?

Example:

  • Login page: green background
  • Home: blue background

1 answer

-1


You can do this from any of its components. For example:

 export class AppComponent implements AfterViewInit {
       constructor(private elementRef: ElementRef){

       }
       ngAfterViewInit(){
         this.elementRef.nativeElement.ownerDocument.body.style.backgroundColor = 'yourColor';
      }
   }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.