# ngx-asyncscripts

> Lazy loading scripts in an Angular 2 lazy loaded module? No probs!

Latest version **1.0.3** (published 2017-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-asyncscripts
pnpm add ngx-asyncscripts
yarn add ngx-asyncscripts
bun add ngx-asyncscripts
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-03-02 |
| First published | 2017-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Rok Knez |
| Maintainers | zenkkor |
| Keywords | angular, angular2, async, scripts, external, load, promise |

## Links

- npm: https://www.npmjs.com/package/ngx-asyncscripts
- Repository: https://github.com/zenkkor/ngx-asyncscripts
- Homepage: https://github.com/zenkkor/ngx-asyncscripts#readme
- Issues: https://github.com/zenkkor/ngx-asyncscripts/issues
- npm.io page: https://npm.io/package/ngx-asyncscripts

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2017-03-02
- 1.0.2 — 2017-02-27
- 1.0.1 — 2017-02-27
- 1.0.0 — 2017-02-27

## README

# ngx-asyncscripts
Lazy loading scripts in an Angular 2 lazy loaded module? No probs!  


# How to install?  

`$ npm install ngx-asyncscripts`   

**Import the Service**   

```
import { NgXAsyncScripts } from 'ngx-asyncscripts';
```    

**Use in your component**  
*For the second parameter of your dependencies array, you can use css or js*
*Provide any additional attributes in the third parameter as an object*

```
export class AppComponent {


	constructor(private asnycScriptsService: NgXAsyncScripts)
	{

		/**
		 * Loads all the dependencies before proceeding
		 * @type {Array<Array<string | string | any>>}
		 */
		let dependencies = [
			["<DEPENDENCY_URL", "js"],
			["<DEPENDENCY_URL", "css"],
			["<DEPENDENCY_URL", "js", {"data-cfasync": "false"}],
		]

		/**
		 * Load services and return a promise.
		 * Do stuff after promise resolves
		 */
		asnycScriptsService.loadExternalDependencies(dependencies).then(
			function(success){
				console.log(success);
			}, function(error){
				console.log(error);
		});
	}
}
```

---
_Source: https://npm.io/package/ngx-asyncscripts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
