Skip to content

Commit

Permalink
fix(): Added ToastyConfig into DI
Browse files Browse the repository at this point in the history
  • Loading branch information
akserg committed Dec 22, 2016
1 parent 883bc29 commit 37be863
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
});
```
Expand Down
7 changes: 5 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions src/toasty.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 37be863

Please sign in to comment.