/** Angular Imports */ import { Injectable } from '@angular/core' ; /**
 * Theme manager service.
 */ @ Injectable ( { providedIn : 'root' } ) export class ThemeManagerService { /** Stylesheet class for the theme of the application. */ private themeManagerClass = 'theme-manager' ; constructor ( ) { } param { string } href setTheme ( href ) { this . getLinkElement ( ) . setAttribute ( 'href' , href ) ; } /**
     * Removes the current theme of the application.
     */ removeTheme ( ) { const existingLinkElement = this . getExistingLinkElement ( ) ; if ( existingLinkElement ) { document . head . removeChild ( existingLinkElement ) ; } } returns private getLinkElement ( ) { return this . getExistingLinkElement ( ) || this . createLinkElement ( ) ; } returns private getExistingLinkElement ( ) { return document . head . querySelector ( `link[rel="stylesheet"].${ this . themeManagerClass }` ) ; } returns private createLinkElement ( ) { const linkElement = document . createElement ( 'link' ) ; linkElement . setAttribute ( 'rel' , 'stylesheet' ) ; linkElement . classList . add ( this . themeManagerClass ) ; document . head . appendChild ( linkElement ) ; return linkElement ; } }