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

angular-busy2

v19.0.0

Published

Angular Busy 2

Downloads

1,203

Readme

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