npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng4-loader-bar

v1.0.3

Published

Angular component that shows a loading bar at the top of a component or module

Downloads

9

Readme

Angular(v4) component that shows a loading bar at the top of a component or module

Build Status dependencies Status devDependencies Status peerDependencies Status Known Vulnerabilities

Installation

npm install ng4-loader-bar --save

Usage

Using SystemJS to load your files may require a update to your config:

System.config({
    map: {
        'ng4-loader-bar': 'node_modules/ng4-loader-bar/bundles/index.umd.js'
    }
});

Update your application/web page with the following markup

  • Import the style.css into your web page or app.
 "styles": [
    "../node_modules/ng4-loader-bar/bundles/style.css"
 ]
  • Add the <ng4-loader-bar></ng4-loader-bar> component tag within the component you want the loading bar to appear:
<div class="my-component">
    <h1>Component with a loading bar</h1>
    <ng4-loader-bar></ng4-loader-bar>
    ...   
</div>

The default styles are:

color: 'red';
height: '2px';

Import AngularLoadingBarModule

Import AngularLoadingBarModule.forRoot() in the NgModule of your application.

import {NgModule} from '@angular/core';
import {AngularLoadingBarModule} from 'ng4-loader-bar';

@NgModule({
    imports: [
        BrowserModule,
        AngularLoadingBarModule.forRoot()
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
}

Using a shared module allows AngularLoadingBarModule to be exported without having to import it multiple times.

@NgModule({
    imports: [
        BrowserModule,
        AngularLoadingBarModule.forRoot()
    ],
    exports: [BrowserModule, AngularLoadingBarModule],
})
export class SharedModule {
}

Using AngularLoadingBarService in your Angular application

  • Import AngularLoadingBarService from ng4-loader-bar(within your node_modules directory) into your component code:
import {Component} from '@angular/core';
import {AngularLoadingBarService} from 'ng4-loader-bar';

@Component({
    selector: 'app',
    template: `
        <div>Hello world</div>
        <button (click)="startLoadingBar()">Start Loading</button>
        <button (click)="stopLoadingBar()">Stop Loading</button>
        <button (click)="completeLoadingBar()">Complete Loading</button>
        <ng4-loader-bar></ng4-loader-bar>
    `
})
export class AppComponent {
    
    constructor(private angularLoadingBarService: AngularLoadingBarService) { }
    
    startLoadingBar() {
        this.angularLoadingBarService.start();
    }

    stopLoadingBar() {
        this.angularLoadingBarService.stop();
    }

    completeLoadingBar() {
        this.angularLoadingBarService.complete();
    }
}

Customize the ng4-loader-bar to tailor to your application

Example: <ng4-loader-bar [color]="'green'" [height]="'6px'"></ng4-loader-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 will pause the progress of the loading bar; start() will resume animation from the current position.
  • reset()- Reset the position of loading progress to 0. This method will stop the current progress animation; using start() after reset() will start a new animation from 0.
  • complete() - Set the progress to 100% and hide the progress bar.
Credits
Inspired by ngProgress.js and ng2-slim-loading-bar
License
MIT