7.0.0 • Published 5 years ago

nu-lazy v7.0.0

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

nu-lazy


Lazy load resources for Angular

NPM version Build Status Codecov

Demo

Install

nu-lazy

Usage

import { LazyService } from 'nu-lazy';

export class AppComponent {
  constructor(private srv: LazyService) { }

  async loadBS() {
    const res = await this.srv.load(`https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css`);
    console.log(`bootstrap`, res);
  }

How to use it with:

  • Stackblitz sample available here.

API

nametypedescription
eventsObservable<LazyResult[]>Events change callback
clear()voidClean all cached items
load(paths: string | string[])Promise<LazyResult[]>Load the specified resources, includes .js, .css
loadScript(path: string, innerContent?: string)Promise<LazyResult>Load a script resources
loadStyle(path: string, rel: string = 'stylesheet', innerContent?: string)Promise<LazyResult>Load a style resources

License

nu-lazy is released under the MIT license.