From 37be863b7e4f70052251221e1b31a6735733963c Mon Sep 17 00:00:00 2001 From: Sergey Akopkokhyants Date: Fri, 23 Dec 2016 00:49:14 +0200 Subject: [PATCH] fix(): Added ToastyConfig into DI --- README.md | 5 +---- index.ts | 7 +++++-- src/toasty.service.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0db2764..5db1d21 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,7 @@ If you use SystemJS to load your files, you might have to update your config: ```js System.config({ map: { - 'ng2-toasty': 'node_modules/ng2-toasty' - }, - packages: { - 'ng2-toasty': { defaultExtension: 'js' }, + 'ng2-toasty': 'node_modules/ng2-toasty/bundles/index.umd.js' } }); ``` diff --git a/index.ts b/index.ts index a0d008f..0552fb8 100644 --- a/index.ts +++ b/index.ts @@ -10,9 +10,12 @@ export * from './src/toasty.component'; import { ToastyComponent } from './src/toasty.component'; import { ToastComponent } from './src/toast.component'; -import { ToastyService, toastyServiceFactory } from './src/toasty.service'; +import { ToastyService, ToastyConfig, toastyServiceFactory } from './src/toasty.service'; -export let providers = [{ provide: ToastyService, useFactory: toastyServiceFactory }]; +export let providers = [ + ToastyConfig, + { provide: ToastyService, useFactory: toastyServiceFactory, deps: [ToastyConfig] } +]; @NgModule({ imports: [CommonModule], diff --git a/src/toasty.service.ts b/src/toasty.service.ts index 0eaaa16..c455b11 100644 --- a/src/toasty.service.ts +++ b/src/toasty.service.ts @@ -62,8 +62,8 @@ export class ToastyConfig { theme: string = 'default'; } -export function toastyServiceFactory(): ToastyService { - return new ToastyService(new ToastyConfig()); +export function toastyServiceFactory(config: ToastyConfig): ToastyService { + return new ToastyService(config); } /**