Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added forRoot static method for PerfectScrollbarModule #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Providing the global configuration is optional and when used you should only pro

```javascript
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { PERFECT_SCROLLBAR_CONFIG } from 'ngx-perfect-scrollbar';
import { PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar';

const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
Expand All @@ -61,13 +60,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
...
imports: [
...
PerfectScrollbarModule
],
providers: [
{
provide: PERFECT_SCROLLBAR_CONFIG,
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
}
PerfectScrollbarModule.forRoot(DEFAULT_PERFECT_SCROLLBAR_CONFIG)
]
})
```
Expand Down
11 changes: 2 additions & 9 deletions example/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { BrowserModule } from '@angular/platform-browser';

import { FlexLayoutModule } from '@angular/flex-layout';

import { PerfectScrollbarModule, PerfectScrollbarConfigInterface,
PERFECT_SCROLLBAR_CONFIG } from 'ngx-perfect-scrollbar';
import { PerfectScrollbarModule, PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar';

import { AppComponent } from './app.component';

Expand All @@ -23,15 +22,9 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
imports: [
BrowserModule,
FlexLayoutModule,
PerfectScrollbarModule
PerfectScrollbarModule.forRoot(DEFAULT_PERFECT_SCROLLBAR_CONFIG)
],
exports: [
],
providers: [
{
provide: PERFECT_SCROLLBAR_CONFIG,
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
}
]
})
export class AppModule {}
14 changes: 13 additions & 1 deletion src/lib/perfect-scrollbar.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { NgModule } from '@angular/core';
import { NgModule, ModuleWithProviders } from '@angular/core';

import { CommonModule } from '@angular/common';

import { PerfectScrollbarComponent } from './perfect-scrollbar.component';
import { PerfectScrollbarDirective } from './perfect-scrollbar.directive';
import { PerfectScrollbarConfigInterface, PERFECT_SCROLLBAR_CONFIG } from './perfect-scrollbar.interfaces'

@NgModule({
imports: [CommonModule],
declarations: [PerfectScrollbarComponent, PerfectScrollbarDirective],
exports: [CommonModule, PerfectScrollbarComponent, PerfectScrollbarDirective]
})
export class PerfectScrollbarModule {
static forRoot(config?: PerfectScrollbarConfigInterface): ModuleWithProviders {
return {
ngModule: PerfectScrollbarModule,
providers: [
{
provide: PERFECT_SCROLLBAR_CONFIG,
useValue: config
}
]
};
}
}