Created
October 10, 2018 06:18
-
-
Save hamzox/703da6dc50972359f7c6ff1321531a17 to your computer and use it in GitHub Desktop.
Ionic v3 Loading Service/Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| import { LoadingController, Loading } from 'ionic-angular'; | |
| /* | |
| * @Author: hamzox | |
| * @Date: 2018-10-10 10:53:14 | |
| * @Last Modified by: hamzox | |
| * @Last Modified time: 2018-10-10 11:05:01 | |
| * | |
| * @Class: LoaderProvider | |
| * @Description: Create/dismiss loader. | |
| */ | |
| @Injectable() | |
| export class LoaderProvider { | |
| loader: Loading; | |
| constructor( | |
| private loaderCtrl: LoadingController | |
| ) { | |
| this.createLoader(); | |
| } | |
| private createLoader() { | |
| this.loader = this.loaderCtrl.create(); | |
| } | |
| public showLoader() { | |
| this.loader.present(); | |
| } | |
| public hiderLoader() { | |
| this.loader.dismiss(); | |
| } | |
| } | |
| //1. Add it to providers in app.module.ts | |
| //2. Inject it your customize service to any component. e.g. constructor (private loaderService: LoaderProvider) {} | |
| //3. Play with it. e.g. this.loaderService.showLoader(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment