Monday, July 1, 2019

How to get image loader in ionic

How to get  image loader in ionic!. Currently in ionic we use modules to load online images, because we want the application to run in the background when loading images we have to use the ionic image loader.
How to get url image loader in ionic

Ionic image loader là gì?

image loader is module that loads image in a background thread and caches them for later use.

Installation image loader 

1. Install the NPM Package
npm install --save ionic-image-loader
2. Install Required Plugins
npm i --save @ionic-native/file
ionic cordova plugin add cordova-plugin-file
3. Import IonicImageLoader module
add IonicImageLoader.forRoot() in your app's root module
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)
import { IonicImageLoader } from 'ionic-image-loader';

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

Usage
This HTML
<img-loader src="https://path.to/my/image.jpg"></img-loader>
View our example project here: https://github.com/zyramedia/ionic-image-loader-example 

No comments:

Post a Comment