PrimeNg Theme Switch Service File

PHOTO EMBED

Sat Oct 14 2023 08:53:57 GMT+0000 (Coordinated Universal Time)

Saved by @susobhandash #css #json

import { DOCUMENT } from '@angular/common';
import { Inject, Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class ThemeService {
  constructor(@Inject(DOCUMENT) private document: Document) {}

  switchTheme(theme: string) {
    let themeLink = this.document.getElementById(
      'app-theme'
    ) as HTMLLinkElement;

    if (themeLink) {
      themeLink.href = theme + '.css';
    }
  }
}
content_copyCOPY