In my current project using Angular 17 and PrimeNG 17, I am implementing a theme switching feature. I have been following a tutorial from the Primeng documentation at this link: https://www.youtube.com/watch?v=5VOuUdDXRsE&embeds_referring_euri=https%3A%2F%2Fprimeng.org%2F&source_ve_path=Mjg2NjY&feature=emb_logo. Below is the code snippet from my theme.service.ts
:
import { Inject, Injectable } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { SystemService } from './system.service';
@Injectable({
providedIn: 'root',
})
export class ThemeService {
constructor(
@Inject(DOCUMENT) private document: Document,
private systemService: SystemService
) {}
switchTheme(theme: string): void {
let themeLink = this.document.getElementById(
'app-theme'
) as HTMLLinkElement;
if (themeLink) {
themeLink.href = 'assets/themes/' + theme + '/theme.css';
this.systemService.setLocalStorage('theme', theme);
}
}
}
Although the app is functioning properly and the theme switching functionality works as intended, I encounter an error message stating
Decorators are not valid here.ts(1206)
at the @Inject
decorator.
I am seeking a solution to address this error or possibly disable the warning altogether. Thank you for any guidance provided.