GithubHelp home page GithubHelp logo

aminholmes / ngx-angular-loading Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bculley/ngx-angular-loading

0.0 1.0 0.0 30 KB

It is a library to makes loading screens easier in Angular (2+)

License: MIT License

JavaScript 8.66% TypeScript 77.08% CSS 14.26%

ngx-angular-loading's Introduction

NGX Angular Loading

Build Status NPM version

It is a library to makes loading screens easier in Angular (2+)

Credits

This project was seeded by https://github.com/darthwade/angular-loading because the author was not responding to pull requests so decided to take what they had started and update and run with it. Along the way we put some of our own opinions on it and added some tests, enough changes that it stopped being a viable PR for the original without serious breaking changes.

Migrating from angularjs dwloading

Markup:

From AngularJS

<div dwLoading="updating" [dwLoadingOptions]="spinnerConfig">

To Angular 2+

<div ngxLoading="updating" [loadingOptions]="spinnerConfig">

Installation

npm install ngx-angular-loading

Step 1. Import the 'NGXLoadingModule' module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NGXLoadingModule } from 'ngx-angular-loading';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NGXLoadingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Step 2. Include NGXLoadingService in your component

Use the service to start and finish the different loading screens You may use $loading for legacy or rename your references to ngxLoadingService

import { Component } from '@angular/core';
import { NGXLoadingService } from 'ngx-angular-loading';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'ngx-angular-loading demo';

  isLoading = false;

  public spinnerConfig: any;

  constructor(private $loading: NGXLoadingService) {
    this.spinnerConfig = {
      text: 'Loading...',
      spinnerOptions: {
          color: '#0078D2'
      }
    };
  }

  public onButtonClick() {
    this.isLoading
      ? this.$loading.finish('updating')
      : this.$loading.start('updating');

    this.isLoading = !this.isLoading;
  }
}

ngx-angular-loading's People

Contributors

bculley avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.