@uirouter/core
Version:
UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps
50 lines (49 loc) • 1.62 kB
TypeScript
import { $InjectorLike } from '../common/index';
/**
* A basic angular1-like injector api
*
* This object implements four methods similar to the
* [angular 1 dependency injector](https://docs.angularjs.org/api/auto/service/$injector)
*
* UI-Router evolved from an angular 1 library to a framework agnostic library.
* However, some of the `@uirouter/core` code uses these ng1 style APIs to support ng1 style dependency injection.
*
* This object provides a naive implementation of a globally scoped dependency injection system.
* It supports the following DI approaches:
*
* ### Function parameter names
*
* A function's `.toString()` is called, and the parameter names are parsed.
* This only works when the parameter names aren't "mangled" by a minifier such as UglifyJS.
*
* ```js
* function injectedFunction(FooService, BarService) {
* // FooService and BarService are injected
* }
* ```
*
* ### Function annotation
*
* A function may be annotated with an array of dependency names as the `$inject` property.
*
* ```js
* injectedFunction.$inject = [ 'FooService', 'BarService' ];
* function injectedFunction(fs, bs) {
* // FooService and BarService are injected as fs and bs parameters
* }
* ```
*
* ### Array notation
*
* An array provides the names of the dependencies to inject (as strings).
* The function is the last element of the array.
*
* ```js
* [ 'FooService', 'BarService', function (fs, bs) {
* // FooService and BarService are injected as fs and bs parameters
* }]
* ```
*
* @type {$InjectorLike}
*/
export declare const $injector: $InjectorLike;