Angular 2 Slim Loading Bar
Angular2 component shows slim loading bar at the top of the page of your application.
Follow me to be notified about new releases.
Some of these APIs and Components are not final and are subject to change!
Installation
npm install ng2-slim-loading-bar --save
Demo
Simple examples using ng2-slim-loading-bar:
- with SystemJS in ng2-systemjs-demo
- with Webpack in ng2-webpack-demo
Online demo available here
Usage
If you use SystemJS to load your files, you might have to update your config:
System;
1. Update the markup
- Import the
style.css
into your web page - Add
<ng2-slim-loading-bar></ng2-slim-loading-bar>
tag in template of your application component.
SlimLoadingBarModule
2. Import the Import SlimLoadingBarModule.forRoot()
in the NgModule of your application.
The forRoot
method is a convention for modules that provide a singleton service.
;;;
If you have multiple NgModules and you use one as a shared NgModule (that you import in all of your other NgModules),
don't forget that you can use it to export the SlimLoadingBarModule
that you imported in order to avoid having to import it multiple times.
SlimLoadingBarService
for your application
3. Use the - Import
SlimLoadingBarService
fromng2-slim-loading-bar
in your application code:
;; @ { } { thisslimLoadingBarServicestart { console; }; } { thisslimLoadingBarService; } { thisslimLoadingBarServicecomplete; }
ng2-slim-loading-bar
for your application
3. Customize the the You can use the following properties to customize the ng2-slim-loading-bar
component in your template:
color
- The color of loading bar. Default isfirebrick
. Any CSS compatible value.height
- The height of loading bar. Default value is2px
.show
- The flag helps hide and show the loading bar. Devault value istrue
.
Example:
<ng2-slim-loading-bar [color]="'blue'" [height]="'4px'"></ng2-slim-loading-bar>
4. Manage the loading bar
You can use the following properties to customize the SlimLoadingBar via instance of SlimLoadingBarService:
color
- The color of loading bar.height
- The height of loading bar.visible
- The flag helps hide and show the loading bar.
You can use the following methods to control the SlimLoadingBar via instance of SlimLoadingBarService:
start
- Start the loading progress. Use the callback function as an parameter to listed the complete event.stop
- Stop the loading progress. This method pause the current position of loading progress.reset
- Reset the position of loading progress to 0.complete
- Set the progress to 100% and hide the progress bar.
Credits
Inspired by ngProgress.js