Skip to content

Commit

Permalink
Fix(module): updated type on module.
Browse files Browse the repository at this point in the history
  • Loading branch information
biutas committed Mar 1, 2021
1 parent 45842af commit fba2edf
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/lib/bootstrap-icons/ng-bootstrap-icons.module.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import { NgModule, ModuleWithProviders, Optional } from '@angular/core';
import { BootstrapIcons } from './ng-bootstrap-icons.component';
import { Icons } from './icons.provider';

import { NgModule, ModuleWithProviders, Optional } from "@angular/core";
import { BootstrapIcons } from "./ng-bootstrap-icons.component";
import { Icons } from "./icons.provider";

@NgModule({
declarations: [
BootstrapIcons
],
exports: [
BootstrapIcons
]
declarations: [BootstrapIcons],
exports: [BootstrapIcons],
})
export class BootstrapIconsModule {
constructor(
@Optional() private icons: Icons
) {
if ( !this.icons ) {
constructor(@Optional() private icons: Icons) {
if (!this.icons) {
throw new Error(
`No icon provided. Make sure to use 'BootstrapIconsModule.pick({ ... })' when importing the module\n` +
`Refer to documentation on https://github.com/biutas/ng-bootstrap-icons/issues`
`Refer to documentation on https://github.com/biutas/ng-bootstrap-icons/issues`
);
}
}

static pick(icons: {[key: string]: string}): ModuleWithProviders {
static pick(icons: {
[key: string]: string;
}): ModuleWithProviders<BootstrapIconsModule> {
return {
ngModule: BootstrapIconsModule,
providers: [
{ provide: Icons, multi: true, useValue: icons }
]
providers: [{ provide: Icons, multi: true, useValue: icons }],
};
}
}

0 comments on commit fba2edf

Please sign in to comment.