# angular-provide

> AngularJS components separation helpers for common.js users.

Latest version **1.1.3** (published 2017-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install angular-provide
pnpm add angular-provide
yarn add angular-provide
bun add angular-provide
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2017-08-31 |
| First published | 2016-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Shota Hoshino |
| Maintainers | hshn |
| Keywords | Angular, Provider |

## Links

- npm: https://www.npmjs.com/package/angular-provide
- Repository: https://github.com/hshn/angular-provide
- Homepage: https://github.com/hshn/angular-provide#readme
- Issues: https://github.com/hshn/angular-provide/issues
- npm.io page: https://npm.io/package/angular-provide

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2017-08-31
- 1.1.3-beta.2 (next) — 2017-08-31
- 1.1.3-beta.1 — 2017-08-31
- 1.1.2 — 2016-09-22
- 1.1.1 — 2016-09-06
- 1.1.0 — 2016-07-01
- 1.0.1 — 2016-07-01
- 1.0.0 — 2016-06-29

## README

angular-provide
===============

[![Build Status](https://travis-ci.org/hshn/angular-provide.svg?branch=master)](https://travis-ci.org/hshn/angular-provide) [![npm version](https://badge.fury.io/js/angular-provide.svg)](https://badge.fury.io/js/angular-provide)

This module provides a way to separate component definitions with component registrations for AngularJS.

The concept which is using in this module are influenced by angular2 `Provider`.

[sample source code here](https://github.com/hshn/angular-provide/tree/master/sample)

# Features

 - Separating component definition with component registrations.
 - Execution order management.

# Usage

## Install

```bash
$ npm install angular-provide --save
```

## Define providers

### Config

```js
import provide from 'angular-provide';

// Configuration will be registered.
let provider = provide.config(function ($someProvider) {
  // ...
});
```

### Provider

```js
import provide from 'angular-provide';

// Provider will be registered as `foo`.
let provider = provide.provider('foo', function () {
  // ...
});
```

### Service

```js
import provide from 'angular-provide';

import { ServiceClass } from './service';

// ServiceClass will be registered as `foo`.
let provider = provide.service('foo', ServiceClass);
```

### Factory

```js
import provide from 'angular-provide';

// Factory will be registered as `foo`.
let provider = provide.factory('foo', function () {
  // ...
});
```

### Directive

```js
import provide from 'angular-provide';

// Directive will be registered as `foo`.
let provider = provide.directive('foo', function () {
  // ...
});
```

### Component

```js
import provide from 'angular-provide';

// Directive will be registered as `foo`.
let provider = provide.component('foo', {
  // ...
});
```

### Run

```js
import provide from 'angular-provide';

// Initialization function will be registered.
let provider = provide.run(function () {
  // ...
});
```
## Working with Providers

### Aggregate providers

```js
import provide from 'angular-provide';

const FOO_PROVIDERS = [
  provide.service('bar', ...),
  provide.factory('baz', ...),
  provide.config(...),
];

// export providers
export FOO_PROVIDERS;
```

### Apply providers to a module

```js
import * as angular from 'angular';
import provide from 'angular-provide';

import { MY_DIRECTIVE_PROVIDERS } from './directives';
import { MY_SERVICE_PROVIDERS } from './services';

// create module
let module = angular.module('myApp', []);

// apply providers to the module
provide(module,
  ...MY_DIRECTIVE_PROVIDERS,
  ...MY_SERVICE_PROVIDERS,
);
```

## Provider priority

`Provider` could have a priority which can specify execution ordering.
It helps defining the process which depends on some other process.

> e.g. http request/response interceptors

Providers will be apply to module in high priority order. (default priority is `0`)

```js
import provide from 'angular-provide';

 // will execute this configuration early than others.
let provider = provide
  .config($httpProvider => {
    $httpProvider.interceptors.push(function () {...})
  })
  .priority(1000)
```

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