17.0.1 • Published 6 months ago

@ng-util/lazy v17.0.1

Weekly downloads
1,557
License
MIT
Repository
github
Last release
6 months ago

@ng-util/lazy

Lazy load javascript, css resources for Angular.

NPM version Build Status codecov Dependency Status prettier GitHub license

Demo

Usage

import { Component } from '@angular/core';
import { NuLazyService } from '@ng-util/lazy';

@Component({
  selector: 'app-demo',
  template: ` <button *ngIf="loaded" type="button" class="btn btn-primary">Primary</button>`,
})
export class DemoComponent {
  loaded = false;

  constructor(private srv: NuLazyService) {
    this.load();
  }

  async load() {
    await this.srv.load([
      `https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css`,
      `https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.bundle.min.js`,
    ]);
    this.loaded = true;
  }
}

API

nametypedescription
monitor(paths: string | Array<string | NuLazyResources>)Observable<NuLazyResult[]>Monitor for the finished of paths
clear()voidClean all cached items
load(paths: string | Array<string | NuLazyResources>)Promise<NuLazyResult[]>Load the specified resources, includes .js, .css
loadScript(path: string, options?: { innerContent?: string })Promise<NuLazyResult>Load a script resources
loadStyle(path: string, options?: { ref?: string, innerContent?: string })Promise<NuLazyResult>Load a style resources

License

The MIT License (see the LICENSE file for the full text)

17.0.0-rc.0

6 months ago

17.0.1

6 months ago

17.0.0

6 months ago

16.0.1

7 months ago

16.0.0

11 months ago

15.0.0

1 year ago

14.0.1

2 years ago

14.0.0

2 years ago

13.1.0

2 years ago

13.0.0

2 years ago

12.1.2

2 years ago

12.1.0

3 years ago

12.1.1

3 years ago

12.0.0

3 years ago

11.2.0

3 years ago

11.1.1

3 years ago

11.1.0

3 years ago

11.0.0

3 years ago

10.2.2

4 years ago

10.2.0

4 years ago

10.2.1

4 years ago

10.1.1

4 years ago

10.1.0

4 years ago

10.1.0-rc.2

4 years ago

10.1.0-rc.1

4 years ago

10.0.0

4 years ago

9.2.0

4 years ago

9.1.1

4 years ago

9.1.0

4 years ago

9.0.0

4 years ago

9.0.0-beta.1

4 years ago