Files
alfresco-content-app/projects/aca-content/src/lib/services/icon.service.ts
2023-02-20 15:54:33 +00:00

31 lines
983 B
TypeScript

/*
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
*
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
*/
import { Injectable } from '@angular/core';
import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';
@Injectable({
providedIn: 'root'
})
export class IconService {
contentIcons: string[] = ['workspace', 'menu', 'avatar'];
constructor(private matIconRegistry: MatIconRegistry, private domSanitizer: DomSanitizer) {}
public registerIcons(): void {
this.loadIcons(this.contentIcons, './assets/svg/icons');
}
private loadIcons(iconKeys: string[], iconUrl: string): void {
iconKeys.forEach((key) => {
this.matIconRegistry.addSvgIcon(key, this.domSanitizer.bypassSecurityTrustResourceUrl(`${iconUrl}/${key}.svg`));
});
}
}