While developing a Login module. I had a theme build in html which i needed to integrate into my login module.
Now it required the body of html to include a custom css(login.page.css).
One way is to add the custom css into the index.html body but then that css will be applied to every page i render in future where i don't even need it. So i tired with this code below...
//FileName: login.component.ts
@Component({
selector: 'login-app' ,
templateUrl: './login.component.html',
styleUrls: ['./login.page.css', './login.component.css']
})
export class LoginComponent implements OnInit {
ngOnInit(){
let body = document.getElementsByTagName('body')[0];
//body.classList.add("theme-default"); //add the class
body.classList.add("page-signin"); //add the class
}
It worked with success on adding the css to body but it failed to change the style of body.