@ngx-loading-bar/core
A fully automatic loading bar with zero configuration for angular app (http, http-client and router).
1. Install @ngx-loading-bar/core
npm install @ngx-loading-bar/core --save
2. Import the LoadingBarModule
:
import { NgModule } from '@angular/core';
import { LoadingBarModule } from '@ngx-loading-bar/core';
@NgModule({
...
imports: [
...
LoadingBarModule.forRoot(),
],
})
export class AppModule {}
3. Include ngx-loading-bar
in your app component:
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
...
<ngx-loading-bar></ngx-loading-bar>
`,
})
export class AppComponent {}
4. include the supplied CSS file (or create your own).
5. Inject/Use LoadingBarService
import { Component } from '@angular/core';
import { LoadingBarService } from '@ngx-loading-bar/core';
@Component({
selector: 'app',
template: `
...
<ngx-loading-bar></ngx-loading-bar>
<button (click)="startLoading()">start</button>
<button (click)="stopLoading()">stop</button>
`,
})
export class App {
constructor(private loadingBar: LoadingBarService) {}
startLoading() {
this.loadingBar.start();
}
stopLoading() {
this.loadingBar.complete();
}
}
Related packages
1.0.0-alpha.18 (2017-11-28)
Bug Fixes
- http: ensure request is cancelled on unsuscribe. (ecea4bf), closes #33
BREAKING CHANGES
- http: http service observables doesn't use subscribe anymore to track request which means you must ensure to subscribe in order to load request
Before
this.http.get('URL');
After
this.http.get('URL').subscribe((v) => {});
<a name="1.0.0-alpha.17"></a>