All Projects → mpalourdio → Ng Http Loader

mpalourdio / Ng Http Loader

Licence: mit
🍡 Smart angular HTTP interceptor - Intercepts automagically HTTP requests and shows a spinkit spinner / loader / progress bar

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ng Http Loader

angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-92.05%)
Mutual labels:  angular2, progress-bar, angular4, angular5, angular6
Aspnetcore Angular Universal
ASP.NET Core & Angular Universal advanced starter - PWA w/ server-side rendering for SEO, Bootstrap, i18n internationalization, TypeScript, unit testing, WebAPI REST setup, SignalR, Swagger docs, and more! By @TrilonIO
Stars: ✭ 1,455 (+344.95%)
Mutual labels:  angular2, angular4, angular5, angular6
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-71.87%)
Mutual labels:  angular2, angular4, angular5, angular6
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (-21.71%)
Mutual labels:  angular2, angular4, angular5, angular6
ng-toggle
Bootstrap-styled Angular Toggle Component
Stars: ✭ 14 (-95.72%)
Mutual labels:  angular2, angular4, angular5, angular6
Springbootangularhtml5
♨️ Spring Boot 2 + Angular 11 + HTML5 router mode + HTTP interceptor + Lazy loaded modules
Stars: ✭ 89 (-72.78%)
Mutual labels:  angular2, angular4, angular5, angular6
spring-websocket-angular6
Example for using Spring Websocket and Angular with Stomp Messaging
Stars: ✭ 18 (-94.5%)
Mutual labels:  angular2, angular4, angular5, angular6
Angular Froala Wysiwyg
Angular 4, 5, 6, 7, 8 and 9 plugin for Froala WYSIWYG HTML Rich Text Editor.
Stars: ✭ 696 (+112.84%)
Mutual labels:  angular2, angular4, angular5, angular6
Ngx Daterangepicker Material
Pure Angular 2+ date range picker with material design theme, a demo here:
Stars: ✭ 169 (-48.32%)
Mutual labels:  angular2, angular4, angular5, angular6
Angular5 Seed
Angular5 Seed for Application
Stars: ✭ 222 (-32.11%)
Mutual labels:  angular2, angular4, angular5, angular6
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+750.46%)
Mutual labels:  angular2, angular4, angular5, angular6
ngx-smart-loader
Smart loader handler to manage loaders everywhere in Angular apps.
Stars: ✭ 28 (-91.44%)
Mutual labels:  angular2, loader, angular4, angular5
Ngx Papaparse
Papa Parse wrapper for Angular
Stars: ✭ 83 (-74.62%)
Mutual labels:  angular2, angular4, angular5, angular6
Ng2 Flatpickr
Angular 2+ wrapper for flatpickr (https://github.com/chmln/flatpickr)
Stars: ✭ 91 (-72.17%)
Mutual labels:  angular2, angular4, angular5, angular6
Nebular
💥 Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+2153.21%)
Mutual labels:  angular2, angular4, angular5, angular6
Ng Simple Slideshow
A simple, responsive slideshow for Angular 4+.
Stars: ✭ 119 (-63.61%)
Mutual labels:  angular2, angular4, angular5, angular6
Ngx Monaco Editor
Monaco Editor component for Angular 2 and Above
Stars: ✭ 347 (+6.12%)
Mutual labels:  angular2, angular4, angular5, angular6
Angular Material App
基于最新Angular 9框架与Material 2技术的web中后台前端应用框架。
Stars: ✭ 509 (+55.66%)
Mutual labels:  angular2, angular4, angular5, angular6
Ng2 Pdfjs Viewer
An angular 8 component for PDFJS and ViewerJS (Supports angular 2/4/5/6/7)
Stars: ✭ 150 (-54.13%)
Mutual labels:  angular2, angular4, angular5, angular6
AuthGuard
Example repo for guarding routes post
Stars: ✭ 42 (-87.16%)
Mutual labels:  angular2, angular4, angular5, angular6

ng-http-loader

Build Status Coverage Status npm npm npm

Changelog

Please read the changelog

Contributing

Use the fork, Luke. PR without tests will likely not be merged.

Installation

To install this library, run:

$ npm install ng-http-loader --save / yarn add ng-http-loader

What does it do ?

This package provides an HTTP Interceptor, and some spinner components (All from SpinKit at the moment). The HTTP interceptor listens to all HTTP requests and shows a spinner / loader indicator during pending HTTP requests.

Angular Compatibility

ng-http-loader Angular
>=0.1.0 <0.4.0 ^4.3.0
>=0.4.0 <1.0.0 ^5.0.0
>=1.0.0 <3.2.0 ^6.0.0
>=3.2.0 <5.1.0 ^7.0.0
>=6.0.0 <7.0.0 ^8.0.0
>=7.0.0 <8.0.0 ^9.0.0
>=8.0.0 <9.0.0 ^10.0.0
>=9.0.0 ^11.0.0

If you experience errors like below, please double check the version you use.

ERROR in Error: Metadata version mismatch for module [...]/angular/node_modules/ng-http-loader/ng-http-loader.module.d.ts, found version x, expected y [...]

Requirements - HttpClientModule

Performing HTTP requests with the HttpClientModule API is mandatory. Otherwise, the spinner will not be fired at all.

See this blog post for an HttpClientModule introduction.

Usage

From your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
// [...]
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http'; // <============
import { NgHttpLoaderModule } from 'ng-http-loader'; // <============

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule, // <============ (Perform HTTP requests with this module)
    NgHttpLoaderModule.forRoot(), // <============ Don't forget to call 'forRoot()'!
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In your app.component.html, simply add:

<ng-http-loader></ng-http-loader>

Customizing the spinner

You can customize the following parameters:

  • The spinner backdrop (visible by default).
  • The background-color (ie. the color of the spinner itself).
  • The debounce delay (ie. after how many milliseconds the spinner will be visible, if needed).
  • The extra duration (ie. how many extra milliseconds should the spinner be visible).
  • The minimum duration (ie. how many milliseconds should the spinner be visible at least).
  • The spinner opacity.
  • The backdrop background-color (ie. the color of the spinner backdrop, if enabled).
  • The spinner type.
<ng-http-loader 
    [backdrop]="false"
    [backgroundColor]="'#ff0000'"
    [debounceDelay]="100"
    [extraDuration]="300"
    [minDuration]="300"
    [opacity]=".6"
    [backdropBackgroundColor]="'#777777'"
    [spinner]="spinkit.skWave">
</ng-http-loader>

To specify the spinner type this way, you must reference the Spinkit const as a public property in your app.component.ts:

import { Component } from '@angular/core'; 
import { Spinkit } from 'ng-http-loader'; // <============

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css'],
})
export class AppComponent {
    public spinkit = Spinkit; // <============
}

The different spinners available are referenced in this file.

Otherwise, you can reference the spinner type as a simple string:

<ng-http-loader spinner="sk-wave"></ng-http-loader>

Defining your own spinner

You can define your own spinner component in place of the built-in ones. The needed steps are:

  • Create your component
  • Add it to the entryComponents array in your module's configuration (not necessary anymore with ivy)
  • Reference your component as a public property in your app.component.ts
  • Reference the predefined property in the ng-http-loader component selector like this:
<ng-http-loader [entryComponent]="myAwesomeComponent"></ng-http-loader>

You can find some examples here and here.

Requests filtering by URL, HTTP method or HTTP headers

You can filter the HTTP requests that shouldn't be caught by the interceptor by providing an array of regex patterns:

<ng-http-loader [filteredUrlPatterns]="['\\d', '[a-zA-Z]', 'my-api']"></ng-http-loader>

You can filter the HTTP requests by providing an array of HTTP methods (case insensitive):

<ng-http-loader [filteredMethods]="['gEt', 'POST', 'PuT']"></ng-http-loader>

You can also filter the HTTP requests by providing an array of HTTP headers (case insensitive):

<ng-http-loader [filteredHeaders]="['hEaDeR', 'AnoTheR-HeAdEr']"></ng-http-loader>

Manually show and hide the spinner

You can manually show and hide the spinner if needed. You must use the SpinnerVisibilityService for this purpose.

Sometimes, when manually showing the spinner, an HTTP request could be performed in background, and when finished, the spinner would automagically disappear.

For this reason, when calling SpinnerVisibilityService#show(), it prevents the HTTP interceptor from being triggered unless you explicitly call SpinnerVisibilityService#hide().

import { Component } from '@angular/core'; 
import { SpinnerVisibilityService } from 'ng-http-loader';

@Component({
    selector: 'my-component',
    templateUrl: './my.component.html',
    styleUrls: ['./my.component.css'],
})
export class MyComponent {

    constructor(private spinner: SpinnerVisibilityService) {
        // show the spinner
        spinner.show();
        //////////////
        // HTTP requests performed between show && hide won't have any side effect on the spinner.
        /////////////
        // hide the spinner
        spinner.hide();
    }
}

Internet explorer or Safari problem ?

Just use a real browser.

Misc

Each Spinkit component defined in SPINKIT_COMPONENTS can be used individually.

Credits

Tobias Ahlin, the awesome creator of SpinKit.
David Herges, the awesome developer of ng-packagr.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].