Files
lucide/packages/lucide-angular/src/lib/lucide-angular.module.ts

29 lines
893 B
TypeScript
Raw Normal View History

import { NgModule, ModuleWithProviders, Optional } from '@angular/core';
import { LucideAngularComponent } from './lucide-angular.component';
import { Icons } from './icons.provider';
2021-04-11 19:04:24 +02:00
import { IconData } from '../icons/types';
@NgModule({
declarations: [LucideAngularComponent],
exports: [LucideAngularComponent]
})
2021-04-14 23:43:47 +02:00
export class LucideAngularModule {
constructor(@Optional() private icons: Icons) {
if (!this.icons) {
throw new Error(
`No icon provided. Make sure to use 'LucideAngularModule.pick({ ... })' when importing the module\n`
);
}
}
static pick(icons: { [key: string]: IconData }): ModuleWithProviders<LucideAngularModule> {
return {
ngModule: LucideAngularModule,
providers: [
{ provide: Icons, multi: true, useValue: icons }
]
};
}
}