ngx-source
TypeScript icon, indicating that this package has built-in type declarations

13.0.2 • Public • Published

ngx source

angular source, can load js and css in runtime

npm version GitHub issues GitHub stars GitHub license

Installation

Install through npm:

npm install --save ngx-source

use in one of your apps components:

import { Component, OnInit } from '@angular/core';
import { Source, SourceType, NgxSourceService } from 'ngx-source';

@Component({
  template: 'your-component',
})
export class YourComponent implements OnInit {
  constructor(private ngxSourceService: NgxSourceService) {
    this.ngxSourceService.addSources([
      new Source('yourJsName', '/js/yourJsFile.js', SourceType.SCRIPT),
      new Source('yourCssName', '/css/yourCssFile.js', SourceType.STYLE),
    ]);
  }

  async ngOnInit() {
    await this.ngxSourceService.loadBySourceName('yourJsName');
    await this.ngxSourceService.loadBySourceName('yourCssName');

    // or

    await this.ngxSourceService.loadBySourceNames('yourJsName', 'yourCssName');
  }
}

Package Sidebar

Install

npm i ngx-source

Weekly Downloads

22

Version

13.0.2

License

MIT

Unpacked Size

41.9 kB

Total Files

16

Last publish

Collaborators

  • mehrabisajad