ng-http-progress v1.0.4
Angular $http Progress Bar
YouTube like top attached progress bar to show $http requests in progress (automatic)
(https://img.shields.io/badge/preview-click here-green.svg?style=flat-square)
How does it work?
When you include thatisuday.ng-http-progress module to your app's dependencies, you will automatically get progress bar whenever you send ajax requests through $http service.
You can change the background color and other options in config block using $httpProgressOpsProvider provider of ng-http-progress module.
In general, whenever your app send one or more $http requests, progress bar will show up and progress will start. At each second, progress bar width will increment by 5% until it reaches 90%. At 90% progress, progress bar will pause and stay like that until all ajax requests finishes. When all ajax requests finishes, progress bar will reach 100% progress and disappear. If all ajax requests finishes before progress reaches 90%, it will jump to 100% and disappear. You can change pause value of 90% to any number between 0 - 100 in config phase.
It consumes only 2kb (gzipped) and it's very hackable.
Install
bower
bower install ng-http-progressnpm
npm install ng-http-progressinclude
ng-http-progress.jsandng-http-progress.cssfromdistdirectory.
Config / Options
angular
.module('demo', ['thatisuday.ng-http-progress'])
.config(function($httpProgressOpsProvider){
$httpProgressOpsProvider.setOps({
background: '#b91f1f',
autoPauseAt : 90,
http : true
});
})all above values are default values, you can avoid any options or entire
configblock if you want.
| option | value | role |
|---|---|---|
| background | hex/rgba | background color of progress bar |
| startAt | 0 - 100 | start progress bar with initial progress |
| autoPauseAt | 0 - 100 | where progress bar will pause until requests resolve |
| http | true/false | automatic show/hide progress bar for $http requests |
Events
If you wish to show progress bar other than just $http requests, then you can use events to show/hide/pause/resume progress bar. Ex. $rootScope.$emit('$httpProgressStart');
| event name | emit from | role |
|---|---|---|
| $httpProgressStart | $rootScope | show/start progress bar |
| $httpProgressPause | $rootScope | pause progress bar |
| $httpProgressResume | $rootScope | resume progress bar |
| $httpProgressRestart | $rootScope | restart progress bar |
| $httpProgressStop | $rootScope | stop/hide progress bar |
Build on your own
You can build this directive with your own customization using gulp.
- Go to repository's parent directory and install all node dev dependencies using
npm install --dev. - Make sure you have gulp install globally. Else use
npm install -g gulpto install gulp globally. - All css for this repository has been generated using sass (.scss), so you need to spend 5 mins to learn basics of sass.
- To build or watch the changes, use command
gulp buildorgulp watch
Contributions and Bug reports
- Please create an issue if you need some help or report a bug.
- Take a pull request to add more features or fix the bugs. Please mention your changes in the PR.
- Please make sure you recommend good practices if you came/come across any or if something could have been better in this module.