Skip to content

Commit

Permalink
fix(SweetAlert2Module): fix code making Angular AoT producing broken …
Browse files Browse the repository at this point in the history
…metadata
  • Loading branch information
toverux committed Sep 2, 2019
1 parent d1f0bc3 commit baffd8b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions projects/ngx-sweetalert2/src/lib/sweetalert2.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,26 @@ export function provideDefaultSwal() {
})
export class SweetAlert2Module {
public static forRoot(options: Sweetalert2ModuleConfig = {}): ModuleWithProviders {
const { provideSwal = provideDefaultSwal, dismissOnDestroy = true } = options;

return {
ngModule: SweetAlert2Module,
providers: [
SweetAlert2LoaderService,
{ provide: swalProviderToken, useValue: provideSwal },
{ provide: dismissOnDestroyToken, useValue: dismissOnDestroy }
{ provide: swalProviderToken, useValue: options.provideSwal || provideDefaultSwal },
{ provide: dismissOnDestroyToken, useValue: options.dismissOnDestroy || true }
]
};
}

public static forChild(options: Sweetalert2ModuleConfig = {}): ModuleWithProviders {
const { provideSwal, dismissOnDestroy } = options;

return {
ngModule: SweetAlert2Module,
providers: [
...options.provideSwal ? [
SweetAlert2LoaderService,
{ provide: swalProviderToken, useValue: provideSwal }
{ provide: swalProviderToken, useValue: options.provideSwal }
] : [],
...options.dismissOnDestroy !== undefined ? [
{ provide: dismissOnDestroyToken, useValue: dismissOnDestroy }
{ provide: dismissOnDestroyToken, useValue: options.dismissOnDestroy }
] : []
]
};
Expand Down

0 comments on commit baffd8b

Please sign in to comment.