Skip to content

Commit

Permalink
feat(): add forRoot method for module
Browse files Browse the repository at this point in the history
  • Loading branch information
ihadeed committed Apr 4, 2017
1 parent 1039f8e commit 6881a1f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,33 @@ npm i --save @ionic-native/transfer
ionic plugin add cordova-plugin-file-transfer --save
```

#### 3. Import `IonicImageLoader` module into your app's module.
#### 3. Import `IonicImageLoader` module

**Add `IonicImageLoader.forRoot()` in your app's root module**
```typescript
import { IonicImageLoader } from 'ionic-image-loader';

// import the module
@NgModule({
...
imports: [
IonicImageLoader.forRoot()
]
})
export class AppModule {}
```

Then **add `IonicImageLoader` in your child/shared module(s)
```typescript
import { IonicImageLoader } from 'ionic-image-loader';

@NgModule({
...
imports: [
IonicImageLoader
]
})
export class SharedModule {}
```

# Usage
Expand Down
22 changes: 14 additions & 8 deletions src/image-loader.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NgModule } from '@angular/core';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { ImgLoader } from './components/img-loader';
import { ImageLoader } from './providers/image-loader';
import { ImageLoaderConfig } from './providers/image-loader-config';
Expand All @@ -10,17 +10,23 @@ import { Transfer } from '@ionic-native/transfer';
declarations: [
ImgLoader
],
providers: [
ImageLoaderConfig,
ImageLoader,
File,
Transfer
],
imports: [
IonicModule
],
exports: [
ImgLoader
]
})
export class IonicImageLoader {}
export class IonicImageLoader {
static forRoot(): ModuleWithProviders {
return {
ngModule: IonicImageLoader,
providers: [
ImageLoaderConfig,
ImageLoader,
File,
Transfer
]
};
}
}

0 comments on commit 6881a1f

Please sign in to comment.