Lazy load javascript, css resources for Angular.
npm install @ng-util/lazyLazy load javascript, css resources for Angular.






``ts
import { Component } from '@angular/core';
import { NuLazyService } from '@ng-util/lazy';
@Component({
selector: 'app-demo',
template: ,
})
export class DemoComponent {
private srv = inject(NuLazyService);
loaded = false;
constructor() {
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;
}
}
| name | type | description |
| ---- | -- | ----------- |
| monitor(paths: string | Array | Observable | Monitor for the finished of paths |clear()
| | void | Clean all cached items |load(paths: string | Array
| | Promise | Load the specified resources, includes .js, .css |loadScript(path: string, options?: { innerContent?: string })
| | Promise | Load a script resources |loadStyle(path: string, options?: { ref?: string, innerContent?: string })
| | Promise
The MIT License (see the LICENSE file for the full text)