ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - tiberiuzuld/angular-busy: Show busy/loading indicators on any element during a promise/Observable.
Show busy/loading indicators on any element during a promise/Observable. - tiberiuzuld/angular-busy
Visit Site

GitHub - tiberiuzuld/angular-busy: Show busy/loading indicators on any element during a promise/Observable.

GitHub - tiberiuzuld/angular-busy: Show busy/loading indicators on any element during a promise/Observable.

angular-busy2 Live Demo

npm version Node CI downloads Donate

Show busy/loading indicators on Observable, Subscription, Promise, Boolean, Number

For AngularJS 1 branch 1.x

Getting Started

Install with npm.

npm install angular-busy2 --save

Add CgBusyModule as a module dependency for your module.

You have to import it with forRoot in any module where you want to provide CgBusyDefaults.

Usually you do that in your root module (app.module).

If you never import it with forRoot CgBusyDefaults will always be undefined.

forRoot takes optional CgBusyOptions as parameter.

For every omitted option in the supplied CgBusyOptions the libraries default value will be used.

import { CgBusyModule } from 'angular-busy2';

@NgModule({
  imports: [
    CgBusyModule.forRoot({
      backdrop: true
    }) //import it with .forRoot in your root module. provide some optional Options.
  ]
})

In every shared module/sub module you should import CgBusyModule without forRoot unless you want to provide a different instance of CgBusyDefaults

Standalone import directive

import { CgBusyDirective } from 'angular-busy2';

@Component({
  standalone: true,
  imports: [CgBusyDirective],
  // ...
})

// main.ts if you bootstrap application
bootstrapApplication(AppComponent, {
  providers: [
    importProvidersFrom(CgBusyModule.forRoot())
    // ...
  ]
}).catch(err => console.log(err));

Options

The [cgBusy] directive expects any Observable, Subscription, Promise, Boolean, Number and optional [cgBusyConfig] configuration object.

In other words. You may do this:


<div [cgBusy]="promise"></div>

or this:


<div [cgBusy]="promise"
     [cgBusyConfig]="{templateRef: customTemplate, message:message, backdrop:backdrop, delay:delay, minDuration:minDuration}"></div>
  • promise - Required. The promise/Observables (or array of promises/Observables) that will cause the busy indicator to show. Also supports boolean and numbers (truthy values will show loading...)
  • message - Optional. Defaults to 'Please Wait...'. The message to show in the indicator. This value may be updated while the promise is active. The indicator will reflect the updated values as they're changed.
  • backdrop - Optional. Boolean, default is true. If true a faded backdrop will be shown behind the progress indicator.
  • templateRef - Optional. If provided, the given template will be shown in place of the default progress indicator template.
  • delay - Optional. The amount of time to wait until showing the indicator. Defaults to 0. Specified in milliseconds.
  • minDuration - Optional. The amount of time to keep the indicator showing even if the promise was resolved quicker. Defaults to 0. Specified in milliseconds.
  • wrapperClass - Optional. The name(s) of the CSS classes to be applied to the wrapper element of the busy sign/animation. Defaults to undefined. Typically only useful if you wish to apply different positioning to the animation.

Overriding Defaults

The default values for message, backdrop, templateRef, delay, and minDuration may all be overridden by overriding the CgBusyDefaults, like so:

import { CgBusyDefaults } from 'angular-busy2';

class AppComponent {
  @ViewChild('customTemplate')
  private customTemplateTpl: TemplateRef<any>;

  constructor(private busyDefaults: CgBusyDefaults) {
    this.busyDefaults.delay = 5000;
  }

  ngOnInit() {
    this.busyDefaults.templateRef = this.customTemplateTpl;
  }
}

<ng-template #customTemplate let-options="options">
  <div class="custom-template">
    <div class="custom-message" [innerHtml]="options.message"></div>
  </div>
</ng-template>

Only the values you'd like overridden need to be specified.

Fork from original angular-busy (cgBusy) https://github.com/cgross/angular-busy

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory