Angular HTTP Loader and Spinner

19.0.0 · active · verified Wed Apr 22

ng-http-loader is an Angular library that provides an automatic loading spinner or progress bar during pending HTTP requests. It achieves this by leveraging Angular's `HttpClient` interceptor mechanism, displaying a visual indicator whenever an active HTTP request is in progress and hiding it once all requests are complete. The current stable version is 19.0.0, which supports Angular 21. The library maintains a rapid release cadence, with new major versions typically released shortly after corresponding Angular major versions to ensure full compatibility and adopt the latest Angular features, such as standalone components, signals, and zoneless change detection. Key differentiators include its tight integration with `HttpClient`, support for various SpinKit-based loaders, and its proactive adoption of modern Angular APIs, providing a streamlined developer experience for adding visual feedback to asynchronous operations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate `ng-http-loader` into a modern Angular standalone application, including importing the loader component and configuring the functional HTTP interceptor.

import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { NgHttpLoaderComponent, pendingRequestsInterceptor$ } from 'ng-http-loader';
import { Component } from '@angular/core';

// app.component.ts
@Component({
    selector: 'app-root',
    standalone: true,
    template: `
        <h1>My Angular App</h1>
        <ng-http-loader></ng-http-loader>
        <router-outlet></router-outlet>
    `,
    styles: [`h1 { color: #333; }`],
    imports: [NgHttpLoaderComponent] // <====== import the component
})
export class AppComponent {
    title = 'my-angular-app';
}

// app.config.ts
import { routes } from './app.routes'; // Assuming you have app.routes defined
export const appConfig: ApplicationConfig = {
    providers: [
        provideRouter(routes),
        provideHttpClient(withInterceptors([pendingRequestsInterceptor$])),
    ],
};

// Example of app.routes.ts (for context)
// import { Routes } from '@angular/router';
// export const routes: Routes = [];

view raw JSON →