ngx-source
Advanced tools
+1
-1
| { | ||
| "name": "ngx-source", | ||
| "version": "1.3.0", | ||
| "version": "1.3.1", | ||
| "peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular/common": "~6.1.10", |
+15
-23
| # ngx source | ||
| [](https://travis-ci.org/mehrabisajad/ngx-source) | ||
| [](https://codecov.io/gh/mehrabisajad/ngx-source) | ||
| angular source, can load js and css in runtime | ||
| [](http://badge.fury.io/js/ngx-source) | ||
| [](https://david-dm.org/mehrabisajad/ngx-source?type=dev) | ||
| [](https://github.com/mehrabisajad/ngx-source/issues) | ||
@@ -10,11 +9,2 @@ [](https://github.com/mehrabisajad/ngx-source/stargazers) | ||
| ## Table of contents | ||
| - [About](#about) | ||
| - [Installation](#installation) | ||
| ## About | ||
| angular source, can load js and css in runtime | ||
| ## Installation | ||
@@ -29,24 +19,26 @@ | ||
| ```typescript | ||
| import { Component,OnInit } from '@angular/core'; | ||
| import { Source, SourceType, NgxSourceService } from "ngx-source"; | ||
| import { Component, OnInit } from '@angular/core'; | ||
| import { Source, SourceType, NgxSourceService } from 'ngx-source'; | ||
| @Component({ | ||
| template: '' | ||
| template: 'your-component' | ||
| }) | ||
| export class MyComponent implements OnInit { | ||
| export class YourComponent implements OnInit { | ||
| constructor(private ngxSourceService: NgxSourceService) { | ||
| this.ngxSourceService.addSource( | ||
| new Source('jquery', '/js/jquery.js', SourceType.SCRIPT) | ||
| ); | ||
| this.ngxSourceService.addSources([ | ||
| new Source('yourJsName', '/js/yourJsFile.js', SourceType.SCRIPT), | ||
| new Source('yourCssName', '/css/yourCssFile.js', SourceType.STYLE) | ||
| ]); | ||
| } | ||
| async ngOnInit() { | ||
| await this.ngxSourceService.load('jquery'); | ||
| await this.ngxSourceService.loadBySourceName('yourJsName'); | ||
| await this.ngxSourceService.loadBySourceName('yourCssName'); | ||
| // use it | ||
| // or | ||
| await this.ngxSourceService.loadBySourceNames('yourJsName', 'yourCssName'); | ||
| } | ||
| } | ||
| ``` |
130567
-0.17%43
-15.69%