https://github.com/mehrabisajad/ngx-source
angular source, can load js and css in runtime
https://github.com/mehrabisajad/ngx-source
Last synced: 7 months ago
JSON representation
angular source, can load js and css in runtime
- Host: GitHub
- URL: https://github.com/mehrabisajad/ngx-source
- Owner: mehrabisajad
- Created: 2020-07-24T16:06:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T08:19:32.000Z (almost 2 years ago)
- Last Synced: 2024-03-23T12:13:28.282Z (over 1 year ago)
- Language: TypeScript
- Size: 368 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- fucking-awesome-angular - ngx-source - Dynamically load JavaScript and CSS during application execution. (Third Party Components / Loaders)
- awesome-angular - ngx-source - Dynamically load JavaScript and CSS during application execution. (Third Party Components / Loaders)
- trackawesomelist - ngx-source (⭐1) - Dynamically load JavaScript and CSS during application execution. (Recently Updated / [Jul 26, 2025](/content/2025/07/26/README.md))
README
# ngx source
angular source, can load js and css in runtime
[](http://badge.fury.io/js/ngx-source)
[](https://github.com/mehrabisajad/ngx-source/issues)
[](https://github.com/mehrabisajad/ngx-source/stargazers)
[](https://raw.githubusercontent.com/mehrabisajad/ngx-source/master/LICENSE)
## Installation
Install through npm:
```
npm install --save ngx-source
```
use in one of your apps components:
```typescript
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');
}
}
```