mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-07 16:30:12 +08:00
chore(typescript): updated angular2 files
This commit is contained in:
+5920
File diff suppressed because it is too large
Load Diff
Vendored
+231
-86
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.35
|
||||
// Type definitions for Angular v2.0.0-alpha.36
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -1158,9 +1158,9 @@ declare module ng {
|
||||
|
||||
descendants: boolean;
|
||||
|
||||
isViewQuery: void;
|
||||
isViewQuery: any;
|
||||
|
||||
selector: void;
|
||||
selector: any;
|
||||
|
||||
isVarBindingQuery: boolean;
|
||||
|
||||
@@ -1200,7 +1200,7 @@ declare module ng {
|
||||
|
||||
attributeName: string;
|
||||
|
||||
token: void;
|
||||
token: any;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
@@ -1250,7 +1250,7 @@ declare module ng {
|
||||
* };
|
||||
*
|
||||
* MyComponent.annotations = [
|
||||
* new ng.Component({...})
|
||||
* new ng.Component({...}),
|
||||
* new ng.View({...})
|
||||
* ]
|
||||
* MyComponent.parameters = [
|
||||
@@ -1335,7 +1335,7 @@ declare module ng {
|
||||
* };
|
||||
*
|
||||
* MyComponent.annotations = [
|
||||
* new ng.Component({...})
|
||||
* new ng.Component({...}),
|
||||
* new ng.View({...})
|
||||
* ]
|
||||
* ```
|
||||
@@ -1512,7 +1512,7 @@ declare module ng {
|
||||
* };
|
||||
*
|
||||
* MyComponent.annotations = [
|
||||
* new ng.Component({...})
|
||||
* new ng.Component({...}),
|
||||
* new ng.View({...})
|
||||
* ]
|
||||
* ```
|
||||
@@ -1585,7 +1585,7 @@ declare module ng {
|
||||
* };
|
||||
*
|
||||
* MyComponent.annotations = [
|
||||
* new ng.Component({...})
|
||||
* new ng.Component({...}),
|
||||
* new ng.View({...})
|
||||
* ]
|
||||
* MyComponent.parameters = [
|
||||
@@ -1604,7 +1604,7 @@ declare module ng {
|
||||
|
||||
|
||||
/**
|
||||
* {@link ViewQueryMetadata} factory function.
|
||||
* {@link di/ViewQueryMetadata} factory function.
|
||||
*/
|
||||
var ViewQuery : QueryFactory ;
|
||||
|
||||
@@ -2020,6 +2020,8 @@ declare module ng {
|
||||
*/
|
||||
class WrappedValue {
|
||||
|
||||
static wrap(value: any): WrappedValue;
|
||||
|
||||
wrapped: any;
|
||||
}
|
||||
|
||||
@@ -2075,6 +2077,30 @@ declare module ng {
|
||||
*/
|
||||
class IterableDiffers {
|
||||
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
||||
|
||||
|
||||
/**
|
||||
* Takes an array of {@link IterableDifferFactory} and returns a binding used to extend the
|
||||
* inherited {@link IterableDiffers} instance with the provided factories and return a new
|
||||
* {@link IterableDiffers} instance.
|
||||
*
|
||||
* The following example shows how to extend an existing list of factories,
|
||||
* which will only be applied to the injector for this component and its children.
|
||||
* This step is all that's required to make a new {@link IterableDiffer} available.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ```
|
||||
* @Component({
|
||||
* viewBindings: [
|
||||
* IterableDiffers.extend([new ImmutableListDiffer()])
|
||||
* ]
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
static extend(factories: IterableDifferFactory[]): Binding;
|
||||
|
||||
factories: IterableDifferFactory[];
|
||||
|
||||
find(iterable: Object): IterableDifferFactory;
|
||||
@@ -2104,6 +2130,30 @@ declare module ng {
|
||||
*/
|
||||
class KeyValueDiffers {
|
||||
|
||||
static create(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
||||
|
||||
|
||||
/**
|
||||
* Takes an array of {@link KeyValueDifferFactory} and returns a binding used to extend the
|
||||
* inherited {@link KeyValueDiffers} instance with the provided factories and return a new
|
||||
* {@link KeyValueDiffers} instance.
|
||||
*
|
||||
* The following example shows how to extend an existing list of factories,
|
||||
* which will only be applied to the injector for this component and its children.
|
||||
* This step is all that's required to make a new {@link KeyValueDiffer} available.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ```
|
||||
* @Component({
|
||||
* viewBindings: [
|
||||
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
|
||||
* ]
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
static extend(factories: KeyValueDifferFactory[]): Binding;
|
||||
|
||||
factories: KeyValueDifferFactory[];
|
||||
|
||||
find(kv: Object): KeyValueDifferFactory;
|
||||
@@ -2147,41 +2197,6 @@ declare module ng {
|
||||
const APP_COMPONENT : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a Angular's representation of an Application.
|
||||
*
|
||||
* `ApplicationRef` represents a running application instance. Use it to retrieve the host
|
||||
* component, injector,
|
||||
* or dispose of an application.
|
||||
*/
|
||||
interface ApplicationRef {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentMetadata} type.
|
||||
*/
|
||||
hostComponentType: Type;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentMetadata} instance.
|
||||
*/
|
||||
hostComponent: any;
|
||||
|
||||
|
||||
/**
|
||||
* Dispose (un-load) the application.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the root application {@link Injector}.
|
||||
*/
|
||||
injector: Injector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bootstrapping for Angular applications.
|
||||
*
|
||||
@@ -2323,6 +2338,41 @@ declare module ng {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a Angular's representation of an Application.
|
||||
*
|
||||
* `ApplicationRef` represents a running application instance. Use it to retrieve the host
|
||||
* component, injector,
|
||||
* or dispose of an application.
|
||||
*/
|
||||
interface ApplicationRef {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentMetadata} type.
|
||||
*/
|
||||
hostComponentType: Type;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentMetadata} instance.
|
||||
*/
|
||||
hostComponent: any;
|
||||
|
||||
|
||||
/**
|
||||
* Dispose (un-load) the application.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the root application {@link Injector}.
|
||||
*/
|
||||
injector: Injector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies app root url for the application.
|
||||
*
|
||||
@@ -2338,7 +2388,7 @@ declare module ng {
|
||||
/**
|
||||
* Returns the base URL of the currently running application.
|
||||
*/
|
||||
value: void;
|
||||
value: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -3031,9 +3081,10 @@ declare module ng {
|
||||
* A reference to an Angular ProtoView.
|
||||
*
|
||||
* A ProtoView is a reference to a template for easy creation of views.
|
||||
* (See {@link AppViewManager#createViewInContainer} and {@link AppViewManager#createRootHostView}).
|
||||
* (See {@link AppViewManager#createViewInContainer `AppViewManager#createViewInContainer`} and
|
||||
* {@link AppViewManager#createRootHostView `AppViewManager#createRootHostView`}).
|
||||
*
|
||||
* A `ProtoView` is a foctary for creating `View`s.
|
||||
* A `ProtoView` is a factory for creating `View`s.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
@@ -3303,7 +3354,7 @@ declare module ng {
|
||||
*/
|
||||
class InjectMetadata {
|
||||
|
||||
token: void;
|
||||
token: any;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
@@ -3458,7 +3509,7 @@ declare module ng {
|
||||
*/
|
||||
class DependencyMetadata {
|
||||
|
||||
token: void;
|
||||
token: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -3544,6 +3595,52 @@ declare module ng {
|
||||
class Injector {
|
||||
|
||||
|
||||
/**
|
||||
* Turns a list of binding definitions into an internal resolved list of resolved bindings.
|
||||
*
|
||||
* A resolution is a process of flattening multiple nested lists and converting individual
|
||||
* bindings into a list of {@link ResolvedBinding}s. The resolution can be cached by `resolve`
|
||||
* for the {@link Injector} for performance-sensitive code.
|
||||
*
|
||||
* @param `bindings` can be a list of `Type`, {@link Binding}, {@link ResolvedBinding}, or a
|
||||
* recursive list of more bindings.
|
||||
*
|
||||
* The returned list is sparse, indexed by `id` for the {@link Key}. It is generally not useful to
|
||||
* application code
|
||||
* other than for passing it to {@link Injector} functions that require resolved binding lists,
|
||||
* such as
|
||||
* `fromResolvedBindings` and `createChildFromResolved`.
|
||||
*/
|
||||
static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding>;
|
||||
|
||||
|
||||
/**
|
||||
* Resolves bindings and creates an injector based on those bindings. This function is slower than
|
||||
* the corresponding `fromResolvedBindings` because it needs to resolve bindings first. See
|
||||
* `resolve`
|
||||
* for the {@link Injector}.
|
||||
*
|
||||
* Prefer `fromResolvedBindings` in performance-critical code that creates lots of injectors.
|
||||
*
|
||||
* @param `bindings` can be a list of `Type`, {@link Binding}, {@link ResolvedBinding}, or a
|
||||
* recursive list of more
|
||||
* bindings.
|
||||
* @param `depProvider`
|
||||
*/
|
||||
static resolveAndCreate(bindings: List<Type | Binding | List<any>>, depProvider?: DependencyProvider): Injector;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an injector from previously resolved bindings. This bypasses resolution and flattening.
|
||||
* This API is the recommended way to construct injectors in performance-sensitive parts.
|
||||
*
|
||||
* @param `bindings` A sparse list of {@link ResolvedBinding}s. See `resolve` for the
|
||||
* {@link Injector}.
|
||||
* @param `depProvider`
|
||||
*/
|
||||
static fromResolvedBindings(bindings: List<ResolvedBinding>, depProvider?: DependencyProvider): Injector;
|
||||
|
||||
|
||||
/**
|
||||
* Returns debug information about the injector.
|
||||
*
|
||||
@@ -3699,7 +3796,7 @@ declare module ng {
|
||||
/**
|
||||
* Token used when retrieving this binding. Usually the `Type`.
|
||||
*/
|
||||
token: void;
|
||||
token: any;
|
||||
|
||||
|
||||
/**
|
||||
@@ -3748,7 +3845,7 @@ declare module ng {
|
||||
* expect(injector.get(String)).toEqual('Hello');
|
||||
* ```
|
||||
*/
|
||||
toValue: void;
|
||||
toValue: any;
|
||||
|
||||
|
||||
/**
|
||||
@@ -3784,7 +3881,7 @@ declare module ng {
|
||||
* expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
|
||||
* ```
|
||||
*/
|
||||
toAlias: void;
|
||||
toAlias: any;
|
||||
|
||||
|
||||
/**
|
||||
@@ -3841,7 +3938,7 @@ declare module ng {
|
||||
*/
|
||||
class BindingBuilder {
|
||||
|
||||
token: void;
|
||||
token: any;
|
||||
|
||||
|
||||
/**
|
||||
@@ -3982,6 +4079,8 @@ declare module ng {
|
||||
*/
|
||||
class Dependency {
|
||||
|
||||
static fromKey(key: Key): Dependency;
|
||||
|
||||
key: Key;
|
||||
|
||||
optional: boolean;
|
||||
@@ -4019,7 +4118,19 @@ declare module ng {
|
||||
* Keys are used internally by the {@link Injector} because their system-wide unique `id`s allow the
|
||||
* injector to index in arrays rather than looking up items in maps.
|
||||
*/
|
||||
interface Key {
|
||||
class Key {
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a `Key` for a token.
|
||||
*/
|
||||
static get(token: Object): Key;
|
||||
|
||||
|
||||
/**
|
||||
* @returns the number of keys registered in the system.
|
||||
*/
|
||||
static numberOfKeys: number;
|
||||
|
||||
token: Object;
|
||||
|
||||
@@ -4075,7 +4186,7 @@ declare module ng {
|
||||
|
||||
addKey(injector: Injector, key: Key): void;
|
||||
|
||||
context: void;
|
||||
context: any;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
@@ -4280,7 +4391,7 @@ declare module ng {
|
||||
* instead of writing:
|
||||
*
|
||||
* ```
|
||||
* import {If, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/angular2';
|
||||
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/angular2';
|
||||
* import {OtherDirective} from 'myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@@ -4288,16 +4399,16 @@ declare module ng {
|
||||
* })
|
||||
* @View({
|
||||
* templateUrl: 'myComponent.html',
|
||||
* directives: [If, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, OtherDirective]
|
||||
* directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, OtherDirective]
|
||||
* })
|
||||
* export class MyComponent {
|
||||
* ...
|
||||
* }
|
||||
* ```
|
||||
* one could enumerate all the core directives at once:
|
||||
* one could import all the core directives at once:
|
||||
*
|
||||
* ```
|
||||
* import {coreDirectives} from 'angular2/angular2';
|
||||
* import {CORE_DIRECTIVES} from 'angular2/angular2';
|
||||
* import {OtherDirective} from 'myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@@ -4305,7 +4416,7 @@ declare module ng {
|
||||
* })
|
||||
* @View({
|
||||
* templateUrl: 'myComponent.html',
|
||||
* directives: [coreDirectives, OtherDirective]
|
||||
* directives: [CORE_DIRECTIVES, OtherDirective]
|
||||
* })
|
||||
* export class MyComponent {
|
||||
* ...
|
||||
@@ -4337,9 +4448,9 @@ declare module ng {
|
||||
*/
|
||||
class NgClass {
|
||||
|
||||
initialClasses: void;
|
||||
initialClasses: any;
|
||||
|
||||
rawClass: void;
|
||||
rawClass: any;
|
||||
|
||||
onCheck(): void;
|
||||
|
||||
@@ -4379,6 +4490,10 @@ declare module ng {
|
||||
*/
|
||||
class NgFor {
|
||||
|
||||
static bulkRemove(tuples: List<RecordViewTuple>, viewContainer: ViewContainerRef): List<RecordViewTuple>;
|
||||
|
||||
static bulkInsert(tuples: List<RecordViewTuple>, viewContainer: ViewContainerRef, templateRef: TemplateRef): List<RecordViewTuple>;
|
||||
|
||||
viewContainer: ViewContainerRef;
|
||||
|
||||
templateRef: TemplateRef;
|
||||
@@ -4387,7 +4502,7 @@ declare module ng {
|
||||
|
||||
cdr: ChangeDetectorRef;
|
||||
|
||||
ngForOf: void;
|
||||
ngForOf: any;
|
||||
|
||||
onCheck(): void;
|
||||
}
|
||||
@@ -4424,7 +4539,7 @@ declare module ng {
|
||||
*/
|
||||
class NgIf {
|
||||
|
||||
ngIf: void;
|
||||
ngIf: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -4455,20 +4570,20 @@ declare module ng {
|
||||
* # Example:
|
||||
*
|
||||
* ```
|
||||
* <div ng-style="{'text-align': alignEpr}"></div>
|
||||
* <div [ng-style]="{'text-align': alignExp}"></div>
|
||||
* ```
|
||||
*
|
||||
* In the above example the `text-align` style will be updated based on the `alignEpr` value
|
||||
* In the above example the `text-align` style will be updated based on the `alignExp` value
|
||||
* changes.
|
||||
*
|
||||
* # Syntax
|
||||
*
|
||||
* - `<div ng-style="{'text-align': alignEpr}"></div>`
|
||||
* - `<div ng-style="styleExp"></div>`
|
||||
* - `<div [ng-style]="{'text-align': alignExp}"></div>`
|
||||
* - `<div [ng-style]="styleExp"></div>`
|
||||
*/
|
||||
class NgStyle {
|
||||
|
||||
rawStyle: void;
|
||||
rawStyle: any;
|
||||
|
||||
onCheck(): void;
|
||||
}
|
||||
@@ -4508,7 +4623,7 @@ declare module ng {
|
||||
*/
|
||||
class NgSwitch {
|
||||
|
||||
ngSwitch: void;
|
||||
ngSwitch: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -4529,7 +4644,7 @@ declare module ng {
|
||||
*/
|
||||
class NgSwitchWhen {
|
||||
|
||||
ngSwitchWhen: void;
|
||||
ngSwitchWhen: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -4782,7 +4897,7 @@ declare module ng {
|
||||
*/
|
||||
class NgControlName extends NgControl {
|
||||
|
||||
update: void;
|
||||
update: any;
|
||||
|
||||
model: any;
|
||||
|
||||
@@ -4855,7 +4970,7 @@ declare module ng {
|
||||
|
||||
form: Control;
|
||||
|
||||
update: void;
|
||||
update: any;
|
||||
|
||||
model: any;
|
||||
|
||||
@@ -4893,7 +5008,7 @@ declare module ng {
|
||||
*/
|
||||
class NgModel extends NgControl {
|
||||
|
||||
update: void;
|
||||
update: any;
|
||||
|
||||
model: any;
|
||||
|
||||
@@ -5055,7 +5170,7 @@ declare module ng {
|
||||
|
||||
directives: List<NgControl>;
|
||||
|
||||
ngSubmit: void;
|
||||
ngSubmit: any;
|
||||
|
||||
onChange(_: any): void;
|
||||
|
||||
@@ -5119,7 +5234,7 @@ declare module ng {
|
||||
|
||||
form: ControlGroup;
|
||||
|
||||
ngSubmit: void;
|
||||
ngSubmit: any;
|
||||
|
||||
formDirective: Form;
|
||||
|
||||
@@ -5175,9 +5290,9 @@ declare module ng {
|
||||
|
||||
cd: NgControl;
|
||||
|
||||
onChange: void;
|
||||
onChange: any;
|
||||
|
||||
onTouched: void;
|
||||
onTouched: any;
|
||||
|
||||
renderer: Renderer;
|
||||
|
||||
@@ -5215,9 +5330,9 @@ declare module ng {
|
||||
|
||||
cd: NgControl;
|
||||
|
||||
onChange: void;
|
||||
onChange: any;
|
||||
|
||||
onTouched: void;
|
||||
onTouched: any;
|
||||
|
||||
renderer: Renderer;
|
||||
|
||||
@@ -5267,9 +5382,9 @@ declare module ng {
|
||||
|
||||
value: string;
|
||||
|
||||
onChange: void;
|
||||
onChange: any;
|
||||
|
||||
onTouched: void;
|
||||
onTouched: any;
|
||||
|
||||
renderer: Renderer;
|
||||
|
||||
@@ -5313,6 +5428,16 @@ declare module ng {
|
||||
* ```
|
||||
*/
|
||||
class Validators {
|
||||
|
||||
static required(c:Control): StringMap<string, boolean>;
|
||||
|
||||
static nullValidator(c: any): StringMap<string, boolean>;
|
||||
|
||||
static compose(validators: List<Function>): Function;
|
||||
|
||||
static group(c:ControlGroup): StringMap<string, boolean>;
|
||||
|
||||
static array(c:ControlArray): StringMap<string, boolean>;
|
||||
}
|
||||
|
||||
class NgValidator {
|
||||
@@ -5403,6 +5528,30 @@ declare module ng {
|
||||
|
||||
class RenderDirectiveMetadata {
|
||||
|
||||
static DIRECTIVE_TYPE: any;
|
||||
|
||||
static COMPONENT_TYPE: any;
|
||||
|
||||
static create({id, selector, compileChildren, events, host, properties, readAttributes, type,
|
||||
callOnDestroy, callOnChange, callOnCheck, callOnInit, callOnAllChangesDone,
|
||||
changeDetection, exportAs}: {
|
||||
id?: string,
|
||||
selector?: string,
|
||||
compileChildren?: boolean,
|
||||
events?: List<string>,
|
||||
host?: Map<string, string>,
|
||||
properties?: List<string>,
|
||||
readAttributes?: List<string>,
|
||||
type?: number,
|
||||
callOnDestroy?: boolean,
|
||||
callOnChange?: boolean,
|
||||
callOnCheck?: boolean,
|
||||
callOnInit?: boolean,
|
||||
callOnAllChangesDone?: boolean,
|
||||
changeDetection?: string,
|
||||
exportAs?: string
|
||||
}): RenderDirectiveMetadata;
|
||||
|
||||
id: any;
|
||||
|
||||
selector: string;
|
||||
@@ -5668,8 +5817,6 @@ declare module ng {
|
||||
*/
|
||||
const APP_ID : OpaqueToken ;
|
||||
|
||||
const DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
* Defines when a compiled template should be stored as a string
|
||||
@@ -5764,8 +5911,6 @@ declare module ng {
|
||||
|
||||
var ComponentRef: InjectableReference;
|
||||
|
||||
var Key: InjectableReference;
|
||||
|
||||
}
|
||||
|
||||
declare module "angular2/angular2" {
|
||||
|
||||
Vendored
+689
@@ -0,0 +1,689 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.36
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ***********************************************************
|
||||
// This file is generated by the Angular build process.
|
||||
// Please do not create manual edits or send pull requests
|
||||
// modifying this file.
|
||||
// ***********************************************************
|
||||
|
||||
// angular2/router depends transitively on these libraries.
|
||||
// If you don't have them installed you can install them using TSD
|
||||
// https://github.com/DefinitelyTyped/tsd
|
||||
|
||||
///<reference path="./angular2.d.ts"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* Maps application URLs into application states, to support deep-linking and navigation.
|
||||
*/
|
||||
declare module ngRouter {
|
||||
|
||||
/**
|
||||
* # Router
|
||||
* The router is responsible for mapping URLs to components.
|
||||
*
|
||||
* You can see the state of the router by inspecting the read-only field `router.navigating`.
|
||||
* This may be useful for showing a spinner, for instance.
|
||||
*
|
||||
* ## Concepts
|
||||
* Routers and component instances have a 1:1 correspondence.
|
||||
*
|
||||
* The router holds reference to a number of "outlets." An outlet is a placeholder that the
|
||||
* router dynamically fills in depending on the current URL.
|
||||
*
|
||||
* When the router navigates from a URL, it must first recognizes it and serialize it into an
|
||||
* `Instruction`.
|
||||
* The router uses the `RouteRegistry` to get an `Instruction`.
|
||||
*/
|
||||
class Router {
|
||||
|
||||
navigating: boolean;
|
||||
|
||||
lastNavigationAttempt: string;
|
||||
|
||||
registry: RouteRegistry;
|
||||
|
||||
parent: Router;
|
||||
|
||||
hostComponent: any;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
|
||||
* component.
|
||||
*/
|
||||
childRouter(hostComponent: any): Router;
|
||||
|
||||
|
||||
/**
|
||||
* Register an object to notify of route changes. You probably don't need to use this unless
|
||||
* you're writing a reusable component.
|
||||
*/
|
||||
registerOutlet(outlet: RouterOutlet): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamically update the routing configuration and trigger a navigation.
|
||||
*
|
||||
* # Usage
|
||||
*
|
||||
* ```
|
||||
* router.config([
|
||||
* { 'path': '/', 'component': IndexComp },
|
||||
* { 'path': '/user/:id', 'component': UserComp },
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
config(definitions: List<RouteDefinition>): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
|
||||
*
|
||||
* If the given URL begins with a `/`, router will navigate absolutely.
|
||||
* If the given URL does not begin with `/`, the router will navigate relative to this component.
|
||||
*/
|
||||
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Updates this router and all descendant routers according to the given instruction
|
||||
*/
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): Object;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the contents of this router's outlet and all descendant outlets
|
||||
*/
|
||||
deactivate(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL, returns an instruction representing the component graph
|
||||
*/
|
||||
recognize(url: string): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
|
||||
* router has yet to successfully navigate.
|
||||
*/
|
||||
renavigate(): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
|
||||
* app's base href.
|
||||
*/
|
||||
generate(linkParams: List<any>): Instruction;
|
||||
}
|
||||
|
||||
class RootRouter extends Router {
|
||||
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
|
||||
*
|
||||
* ## Use
|
||||
*
|
||||
* ```
|
||||
* <router-outlet></router-outlet>
|
||||
* ```
|
||||
*/
|
||||
class RouterOutlet {
|
||||
|
||||
childRouter: Router;
|
||||
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Given an instruction, update the contents of this outlet.
|
||||
*/
|
||||
commit(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canDeactivate(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canReuse(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
deactivate(nextInstruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouterLink directive lets you link to specific parts of your app.
|
||||
*
|
||||
* Consider the following route configuration:
|
||||
*
|
||||
* ```
|
||||
* @RouteConfig([
|
||||
* { path: '/user', component: UserCmp, as: 'user' }
|
||||
* ]);
|
||||
* class MyComp {}
|
||||
* ```
|
||||
*
|
||||
* When linking to this `user` route, you can write:
|
||||
*
|
||||
* ```
|
||||
* <a [router-link]="['./user']">link to user component</a>
|
||||
* ```
|
||||
*
|
||||
* RouterLink expects the value to be an array of route names, followed by the params
|
||||
* for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]`
|
||||
* means that we want to generate a link for the `team` route with params `{teamId: 1}`,
|
||||
* and with a child route `user` with params `{userId: 2}`.
|
||||
*
|
||||
* The first route name should be prepended with `/`, `./`, or `../`.
|
||||
* If the route begins with `/`, the router will look up the route from the root of the app.
|
||||
* If the route begins with `./`, the router will instead look in the current component's
|
||||
* children for the route. And if the route begins with `../`, the router will look at the
|
||||
* current component's parent.
|
||||
*/
|
||||
class RouterLink {
|
||||
|
||||
visibleHref: string;
|
||||
|
||||
routeParams: any;
|
||||
|
||||
onClick(): boolean;
|
||||
}
|
||||
|
||||
class RouteParams {
|
||||
|
||||
params: StringMap<string, string>;
|
||||
|
||||
get(param: string): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouteRegistry holds route configurations for each component in an Angular app.
|
||||
* It is responsible for creating Instructions from URLs, and generating URLs based on route and
|
||||
* parameters.
|
||||
*/
|
||||
class RouteRegistry {
|
||||
|
||||
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
*/
|
||||
config(parentComponent: any, config: RouteDefinition): void;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the annotations of a component and configures the registry based on them
|
||||
*/
|
||||
configFromComponent(component: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL and a parent component, return the most specific instruction for navigating
|
||||
* the application into the state specified by the url
|
||||
*/
|
||||
recognize(url: string, parentComponent: any): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
|
||||
* generates a url with a leading slash relative to the provided `parentComponent`.
|
||||
*/
|
||||
generate(linkParams: List<any>, parentComponent: any): Instruction;
|
||||
}
|
||||
|
||||
class LocationStrategy {
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(ctx: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
onPopState(fn: (_: any) => any): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
}
|
||||
|
||||
class HashLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
class PathLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the service that an application developer will directly interact with.
|
||||
*
|
||||
* Responsible for normalizing the URL against the application's base href.
|
||||
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
|
||||
* trailing slash:
|
||||
* - `/my/app/user/123` is normalized
|
||||
* - `my/app/user/123` **is not** normalized
|
||||
* - `/my/app/user/123/` **is not** normalized
|
||||
*/
|
||||
class Location {
|
||||
|
||||
path(): string;
|
||||
|
||||
normalize(url: string): string;
|
||||
|
||||
normalizeAbsolutely(url: string): string;
|
||||
|
||||
go(url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
|
||||
}
|
||||
|
||||
const APP_BASE_HREF : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for performing each step of navigation.
|
||||
* "Steps" are conceptually similar to "middleware"
|
||||
*/
|
||||
class Pipeline {
|
||||
|
||||
steps: List<Function>;
|
||||
|
||||
process(instruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
|
||||
* successful route navigation.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* If `onActivate` returns a promise, the route change will wait until the promise settles to
|
||||
* instantiate and activate child components.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements OnActivate {
|
||||
* onActivate(next, prev) {
|
||||
* this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnActivate {
|
||||
|
||||
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
|
||||
* a component as part of a route change.
|
||||
*
|
||||
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnDeactivate {
|
||||
|
||||
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
|
||||
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnReuse {
|
||||
|
||||
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
|
||||
* if a component can be removed as part of a navigation.
|
||||
*
|
||||
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanDeactivate {
|
||||
* canDeactivate(next, prev) {
|
||||
* return askUserIfTheyAreSureTheyWantToQuit();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanDeactivate {
|
||||
|
||||
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
|
||||
* component should be reused across routes, or whether to destroy and instantiate a new component.
|
||||
*
|
||||
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
|
||||
*
|
||||
* If `canReuse` throws or rejects, the navigation will be cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse(next, prev) {
|
||||
* return next.params.id == prev.params.id;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.id = next.params.id;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanReuse {
|
||||
|
||||
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canActivate], which is called by the router to determine
|
||||
* if a component can be instantiated as part of a navigation.
|
||||
*
|
||||
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
|
||||
* This is because [canActivate] is called before the component is instantiated.
|
||||
*
|
||||
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canActivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'control-panel-cmp'
|
||||
* })
|
||||
* @CanActivate(() => checkIfUserIsLoggedIn())
|
||||
* class ControlPanelCmp {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
|
||||
ClassDecorator ;
|
||||
|
||||
|
||||
/**
|
||||
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
|
||||
* to transition each component in the app to a given route, including all auxiliary routes.
|
||||
*
|
||||
* This is a public API.
|
||||
*/
|
||||
class Instruction {
|
||||
|
||||
component: ComponentInstruction;
|
||||
|
||||
child: Instruction;
|
||||
|
||||
auxInstruction: StringMap<string, Instruction>;
|
||||
|
||||
replaceChild(child: Instruction): Instruction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
|
||||
* composed of a tree of these `ComponentInstruction`s.
|
||||
*
|
||||
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
|
||||
* to route lifecycle hooks, like {@link CanActivate}.
|
||||
*/
|
||||
class ComponentInstruction {
|
||||
|
||||
reuse: boolean;
|
||||
|
||||
urlPath: string;
|
||||
|
||||
urlParams: List<string>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
componentType: any;
|
||||
|
||||
resolveComponentType(): Promise<Type>;
|
||||
|
||||
specificity: any;
|
||||
|
||||
terminal: any;
|
||||
|
||||
routeData(): Object;
|
||||
}
|
||||
|
||||
class Url {
|
||||
|
||||
path: string;
|
||||
|
||||
child: Url;
|
||||
|
||||
auxiliary: List<Url>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
toString(): string;
|
||||
|
||||
segmentToString(): string;
|
||||
}
|
||||
|
||||
class OpaqueToken {
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runtime representation of a type.
|
||||
*
|
||||
* In JavaScript a Type is a constructor function.
|
||||
*/
|
||||
interface Type extends Function {
|
||||
|
||||
new(args: any): any;
|
||||
|
||||
}
|
||||
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
const ROUTER_DIRECTIVES : List<any> ;
|
||||
|
||||
const ROUTER_BINDINGS : List<any> ;
|
||||
|
||||
class Route implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class Redirect implements RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
redirectTo: string;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
data: any;
|
||||
}
|
||||
|
||||
class AuxRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class AsyncRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
as: string;
|
||||
}
|
||||
|
||||
interface RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
component?: Type | ComponentDefinition;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
redirectTo?: string;
|
||||
|
||||
as?: string;
|
||||
|
||||
data?: any;
|
||||
}
|
||||
|
||||
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
|
||||
|
||||
interface ComponentDefinition {
|
||||
|
||||
type: string;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
component?: Type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "angular2/router" {
|
||||
export = ngRouter;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+11
-11
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.35
|
||||
// Type definitions for Angular v2.0.0-alpha.36
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -109,7 +109,7 @@ declare module ngRouter {
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): void;
|
||||
subscribe(onNext: (value: any) => void): Object;
|
||||
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ declare module ngRouter {
|
||||
|
||||
visibleHref: string;
|
||||
|
||||
routeParams: void;
|
||||
routeParams: any;
|
||||
|
||||
onClick(): boolean;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ declare module ngRouter {
|
||||
back(): void;
|
||||
}
|
||||
|
||||
class HTML5LocationStrategy extends LocationStrategy {
|
||||
class PathLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
@@ -551,13 +551,13 @@ declare module ngRouter {
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
componentType: void;
|
||||
componentType: any;
|
||||
|
||||
resolveComponentType(): Promise<Type>;
|
||||
|
||||
specificity: void;
|
||||
specificity: any;
|
||||
|
||||
terminal: void;
|
||||
terminal: any;
|
||||
|
||||
routeData(): Object;
|
||||
}
|
||||
@@ -594,9 +594,11 @@ declare module ngRouter {
|
||||
|
||||
}
|
||||
|
||||
const routerDirectives : List<any> ;
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
var routerInjectables : List<any> ;
|
||||
const ROUTER_DIRECTIVES : List<any> ;
|
||||
|
||||
const ROUTER_BINDINGS : List<any> ;
|
||||
|
||||
class Route implements RouteDefinition {
|
||||
|
||||
@@ -667,8 +669,6 @@ declare module ngRouter {
|
||||
data?: any;
|
||||
}
|
||||
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
|
||||
|
||||
interface ComponentDefinition {
|
||||
|
||||
Reference in New Issue
Block a user