You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
954 B
30 lines
954 B
import { Component, OnInit } from '@angular/core';
|
|
import { ThemeService } from './services/theme.service';
|
|
import { FooterComponent } from './components/footer/footer.component';
|
|
import { RouterOutlet } from '@angular/router';
|
|
import { HeaderComponent } from './components/header/header.component';
|
|
import { NgClass } from '@angular/common';
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: ['./app.component.scss'],
|
|
standalone: true,
|
|
imports: [NgClass, HeaderComponent, RouterOutlet, FooterComponent]
|
|
})
|
|
|
|
export class AppComponent implements OnInit {
|
|
themeClass = 'light-theme';
|
|
|
|
constructor(public themeService: ThemeService) {}
|
|
|
|
ngOnInit() {
|
|
this.themeService.isDarkTheme.subscribe((isDark) => {
|
|
this.themeClass = isDark ? 'dark-theme' : 'light-theme';
|
|
console.log('Theme class updated:', this.themeClass);
|
|
});
|
|
}
|
|
|
|
toggleTheme() {
|
|
this.themeService.toggleDarkTheme();
|
|
}
|
|
} |