immer noch nach einer besseren Lösung suchen, hier ist meine aktuelle Problemumgehung :
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css',], // Where my custom CSS styles for body element declared
encapsulation: ViewEncapsulation.None, // That will not encapsulate my CSS styles (layout-full, page-signup) from signup.component.css inside component
})
export class SignupComponent implements OnInit, OnDestroy{
bodyClasses:string = "layout-full page-signup";
ngOnInit(): void {
$('body').addClass(this.bodyClasses);
}
ngOnDestroy() {
$('body').removeClass(this.bodyClasses);
}
}
Sie wollen eine CSS-Klasse auf den ''
Tag hinzuzufügen/entfernen? –Ja, wenn ein Benutzer ein Kontrollkästchen aktiviert hat, möchte ich meinen Stil der Seite ändern. Also ich möchte die Klasse des Body-Tags ändern. –
Mögliches Duplikat von [Angular 2.x bind class auf body tag] (http://stackoverflow.com/questions/34430666/angular-2-x-bind-class-on-body-tag) –