Socket
Socket
Sign inDemoInstall

@angular/core

Package Overview
Dependencies
Maintainers
1
Versions
837
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/core - npm Package Compare versions

Comparing version 2.0.0-rc.7 to 2.0.0

README.md

4

bundles/core-testing.umd.js
/**
* @license AngularJS v0.0.0-PLACEHOLDER
* @license Angular v2.0.0
* (c) 2010-2016 Google, Inc. https://angular.io/

@@ -1343,2 +1343,2 @@ * License: MIT

}));
}));
{
"name": "@angular/core",
"version": "2.0.0-rc.7",
"description": "Angular 2 core",
"version": "2.0.0",
"description": "Angular - the core framework",
"main": "bundles/core.umd.js",

@@ -6,0 +6,0 @@ "module": "index.js",

export declare const THROW_IF_NOT_FOUND: Object;
/**
* @whatItDoes Injector interface
* @howToUse
* ```
* const injector: Injector = ...;
* injector.get(...);
* ```
*
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
*
* {@example core/di/ts/injector_spec.ts region='Injector'}
*
* `Injector` returns itself when given `Injector` as a token:
* {@example core/di/ts/injector_spec.ts region='injectInjector'}
*
* @stable

@@ -14,21 +31,5 @@ */

* - Returns the `notFoundValue` otherwise
*
* ### Example ([live demo](http://plnkr.co/edit/HeXSHg?p=preview))
*
* ```typescript
* var injector = ReflectiveInjector.resolveAndCreate([
* {provide: "validToken", useValue: "Value"}
* ]);
* expect(injector.get("validToken")).toEqual("Value");
* expect(() => injector.get("invalidToken")).toThrowError();
* ```
*
* `Injector` returns itself when given `Injector` as a token.
*
* ```typescript
* var injector = ReflectiveInjector.resolveAndCreate([]);
* expect(injector.get(Injector)).toBe(injector);
* ```
*/
get(token: any, notFoundValue?: any): any;
}

@@ -25,2 +25,19 @@ /**

/**
* @whatItDoes Injector interface
* @howToUse
* ```
* const injector: Injector = ...;
* injector.get(...);
* ```
*
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
*
* {@example core/di/ts/injector_spec.ts region='Injector'}
*
* `Injector` returns itself when given `Injector` as a token:
* {@example core/di/ts/injector_spec.ts region='injectInjector'}
*
* @stable

@@ -37,19 +54,3 @@ */

* - Returns the `notFoundValue` otherwise
*
* ### Example ([live demo](http://plnkr.co/edit/HeXSHg?p=preview))
*
* ```typescript
* var injector = ReflectiveInjector.resolveAndCreate([
* {provide: "validToken", useValue: "Value"}
* ]);
* expect(injector.get("validToken")).toEqual("Value");
* expect(() => injector.get("invalidToken")).toThrowError();
* ```
*
* `Injector` returns itself when given `Injector` as a token.
*
* ```typescript
* var injector = ReflectiveInjector.resolveAndCreate([]);
* expect(injector.get(Injector)).toBe(injector);
* ```
*/

@@ -56,0 +57,0 @@ Injector.prototype.get = function (token, notFoundValue) { return unimplemented(); };

@@ -8,25 +8,18 @@ /**

/**
* A parameter metadata that specifies a dependency.
*
* ### Example ([live demo](http://plnkr.co/edit/6uHYJK?p=preview))
*
* ```typescript
* class Engine {}
*
* @whatItDoes A parameter decorator that specifies a dependency.
* @howToUse
* ```
* @Injectable()
* class Car {
* engine;
* constructor(@Inject("MyEngine") engine:Engine) {
* this.engine = engine;
* }
* constructor(@Inject("MyEngine") public engine:Engine) {}
* }
* ```
*
* var injector = Injector.resolveAndCreate([
* {provide: "MyEngine", useClass: Engine},
* Car
* ]);
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* expect(injector.get(Car).engine instanceof Engine).toBe(true);
* ```
* ### Example
*
* {@example core/di/ts/metadata_spec.ts region='Inject'}
*
* When `@Inject()` is not present, {@link Injector} will use the type annotation of the

@@ -37,13 +30,4 @@ * parameter.

*
* ```typescript
* class Engine {}
* {@example core/di/ts/metadata_spec.ts region='InjectWithoutDecorator'}
*
* @Injectable()
* class Car {
* constructor(public engine: Engine) {} //same as constructor(@Inject(Engine) engine:Engine)
* }
*
* var injector = Injector.resolveAndCreate([Engine, Car]);
* expect(injector.get(Car).engine instanceof Engine).toBe(true);
* ```
* @stable

@@ -76,21 +60,19 @@ */

/**
* A parameter metadata that marks a dependency as optional. {@link Injector} provides `null` if
* the dependency is not found.
*
* ### Example ([live demo](http://plnkr.co/edit/AsryOm?p=preview))
*
* ```typescript
* class Engine {}
*
* @whatItDoes A parameter metadata that marks a dependency as optional.
* {@link Injector} provides `null` if the dependency is not found.
* @howToUse
* ```
* @Injectable()
* class Car {
* engine;
* constructor(@Optional() engine:Engine) {
* this.engine = engine;
* }
* constructor(@Optional() public engine:Engine) {}
* }
* ```
*
* var injector = Injector.resolveAndCreate([Car]);
* expect(injector.get(Car).engine).toBeNull();
* ```
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
*
* {@example core/di/ts/metadata_spec.ts region='Optional'}
*
* @stable

@@ -122,31 +104,21 @@ */

/**
* A marker metadata that marks a class as available to {@link Injector} for creation.
* @whatItDoes A marker metadata that marks a class as available to {@link Injector} for creation.
* @howToUse
* ```
* @Injectable()
* class Car {}
* ```
*
* ### Example ([live demo](http://plnkr.co/edit/Wk4DMQ?p=preview))
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ```typescript
* @Injectable()
* class UsefulService {}
* ### Example
*
* @Injectable()
* class NeedsService {
* constructor(public service:UsefulService) {}
* }
* {@example core/di/ts/metadata_spec.ts region='Injectable'}
*
* var injector = Injector.resolveAndCreate([NeedsService, UsefulService]);
* expect(injector.get(NeedsService).service instanceof UsefulService).toBe(true);
* ```
* {@link Injector} will throw {@link NoAnnotationError} when trying to instantiate a class that
* does not have `@Injectable` marker, as shown in the example below.
*
* ```typescript
* class UsefulService {}
* {@example core/di/ts/metadata_spec.ts region='InjectableThrows'}
*
* class NeedsService {
* constructor(public service:UsefulService) {}
* }
*
* var injector = Injector.resolveAndCreate([NeedsService, UsefulService]);
* expect(() => injector.get(NeedsService)).toThrowError();
* ```
* @stable

@@ -178,27 +150,18 @@ */

/**
* Specifies that an {@link Injector} should retrieve a dependency only from itself.
*
* ### Example ([live demo](http://plnkr.co/edit/NeagAg?p=preview))
*
* ```typescript
* class Dependency {
* }
*
* @whatItDoes Specifies that an {@link Injector} should retrieve a dependency only from itself.
* @howToUse
* ```
* @Injectable()
* class NeedsDependency {
* dependency;
* constructor(@Self() dependency:Dependency) {
* this.dependency = dependency;
* }
* class Car {
* constructor(@Self() public engine:Engine) {}
* }
* ```
*
* var inj = Injector.resolveAndCreate([Dependency, NeedsDependency]);
* var nd = inj.get(NeedsDependency);
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* expect(nd.dependency instanceof Dependency).toBe(true);
* ### Example
*
* var inj = Injector.resolveAndCreate([Dependency]);
* var child = inj.resolveAndCreateChild([NeedsDependency]);
* expect(() => child.get(NeedsDependency)).toThrowError();
* ```
* {@example core/di/ts/metadata_spec.ts region='Self'}
*
* @stable

@@ -230,25 +193,18 @@ */

/**
* Specifies that the dependency resolution should start from the parent injector.
* @whatItDoes Specifies that the dependency resolution should start from the parent injector.
* @howToUse
* ```
* @Injectable()
* class Car {
* constructor(@SkipSelf() public engine:Engine) {}
* }
* ```
*
* ### Example ([live demo](http://plnkr.co/edit/Wchdzb?p=preview))
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ```typescript
* class Dependency {
* }
* ### Example
*
* @Injectable()
* class NeedsDependency {
* dependency;
* constructor(@SkipSelf() dependency:Dependency) {
* this.dependency = dependency;
* }
* }
* {@example core/di/ts/metadata_spec.ts region='SkipSelf'}
*
* var parent = Injector.resolveAndCreate([Dependency]);
* var child = parent.resolveAndCreateChild([NeedsDependency]);
* expect(child.get(NeedsDependency).dependency instanceof Depedency).toBe(true);
*
* var inj = Injector.resolveAndCreate([Dependency, NeedsDependency]);
* expect(() => inj.get(NeedsDependency)).toThrowError();
* ```
* @stable

@@ -280,52 +236,20 @@ */

/**
* Specifies that an injector should retrieve a dependency from any injector until reaching the
* closest host.
* @whatItDoes Specifies that an injector should retrieve a dependency from any injector until
* reaching the
* host element of the current component.
* @howToUse
* ```
* @Injectable()
* class Car {
* constructor(@Host() public engine:Engine) {}
* }
* ```
*
* In Angular, a component element is automatically declared as a host for all the injectors in
* its view.
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example ([live demo](http://plnkr.co/edit/GX79pV?p=preview))
* ### Example
*
* In the following example `App` contains `ParentCmp`, which contains `ChildDirective`.
* So `ParentCmp` is the host of `ChildDirective`.
* {@example core/di/ts/metadata_spec.ts region='Host'}
*
* `ChildDirective` depends on two services: `HostService` and `OtherService`.
* `HostService` is defined at `ParentCmp`, and `OtherService` is defined at `App`.
*
*```typescript
* class OtherService {}
* class HostService {}
*
* @Directive({
* selector: 'child-directive'
* })
* class ChildDirective {
* constructor(@Optional() @Host() os:OtherService, @Optional() @Host() hs:HostService){
* console.log("os is null", os);
* console.log("hs is NOT null", hs);
* }
* }
*
* @Component({
* selector: 'parent-cmp',
* providers: [HostService],
* template: `
* Dir: <child-directive></child-directive>
* `,
* directives: [ChildDirective]
* })
* class ParentCmp {
* }
*
* @Component({
* selector: 'app',
* providers: [OtherService],
* template: `
* Parent: <parent-cmp></parent-cmp>
* `,
* directives: [ParentCmp]
* })
* class App {
* }
*```
* @stable

@@ -332,0 +256,0 @@ */

@@ -10,31 +10,23 @@ /**

/**
* Configures the {@link Injector} to return an instance of `Type` when `Type' is used as token.
* @whatItDoes Configures the {@link Injector} to return an instance of `Type` when `Type' is used
* as token.
* @howToUse
* ```
* @Injectable()
* class MyService {}
*
* const provider: TypeProvider = MyService;
* ```
*
* @description
*
* Create an instance by invoking the `new` operator and supplying additional arguments.
* This form is a short form of `TypeProvider`;
*
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
* ```javascript
* @Injectable()
* class Greeting {
* text: 'Hello';
* }
*
* @Injectable()
* class MyClass {
* greeting:string;
* constructor(greeting: Greeting) {
* this.greeting = greeting.text;
* }
* }
* {@example core/di/ts/provider_spec.ts region='TypeProvider'}
*
* const injector = Injector.resolveAndCreate([
* Greeting, // Shorthand for { provide: Greeting, useClass: Greeting }
* MyClass // Shorthand for { provide: MyClass, useClass: MyClass }
* ]);
*
* const myClass: MyClass = injector.get(MyClass);
* expect(myClass.greeting).toEqual('Hello');
* ```
*
* @stable

@@ -45,12 +37,15 @@ */

/**
* Configures the {@link Injector} to return a value for a token.
* @whatItDoes Configures the {@link Injector} to return a value for a token.
* @howToUse
* ```
* const provider: ValueProvider = {provide: 'someToken', useValue: 'someValue'};
* ```
*
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
* ```javascript
* const injector = Injector.resolveAndCreate([
* {provide: String, useValue: 'Hello'}
* ]);
*
* expect(injector.get(String)).toEqual('Hello');
* ```
* {@example core/di/ts/provider_spec.ts region='ValueProvider'}
*
* @stable

@@ -72,13 +67,4 @@ */

* ### Example
* ```javascript
* var locale = new OpaqueToken('local');
*
* const injector = Injector.resolveAndCreate([
* { provide: locale, multi: true, useValue: 'en' },
* { provide: locale, multi: true, useValue: 'sk' },
* ]);
*
* const locales: string[] = injector.get(locale);
* expect(locales).toEqual(['en', 'sk']);
* ```
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
*/

@@ -88,42 +74,20 @@ multi?: boolean;

/**
* Configures the {@link Injector} to return an instance of `useClass` for a token.
* @whatItDoes Configures the {@link Injector} to return an instance of `useClass` for a token.
* @howToUse
* ```
* @Injectable()
* class MyService {}
*
* ### Example
* ```javascript
* abstract class Shape {
* name: string;
* }
*
* class Square extends Shape {
* name = 'square';
* }
*
* const injector = Injector.resolveAndCreate([
* {provide: Shape, useClass: Square}
* ]);
*
* const shape: Shape = injector.get(Shape);
* expect(shape.name).toEqual('square');
* expect(shape instanceof Square).toBe(true);
* const provider: ClassProvider = {provide: 'someToken', useClass: MyService};
* ```
*
* Note that following is not equal:
* ```javascript
* class Greeting {
* salutation = 'Hello';
* }
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* class FormalGreeting extends Greeting {
* salutation = 'Greetings';
* }
* ### Example
*
* const injector = Injector.resolveAndCreate([
* FormalGreeting,
* {provide: Greeting, useClass: FormalGreeting}
* ]);
* {@example core/di/ts/provider_spec.ts region='ClassProvider'}
*
* // The injector returns different instances.
* // See: {provide: ?, useExisting: ?} if you want the same instance.
* expect(injector.get(FormalGreeting)).not.toBe(injector.get(Greeting));
* ```
* Note that following two providers are not equal:
* {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'}
*

@@ -146,26 +110,4 @@ * @stable

* ### Example
* ```javascript
* abstract class Locale {
* name: string;
* };
*
* @Injectable()
* class EnLocale extends Locale {
* name: 'en';
* };
*
* @Injectable()
* class SkLocale extends Locale {
* name: 'sk';
* };
*
* const injector = Injector.resolveAndCreate([
* { provide: Locale, useValue: EnLocale, multi: true },
* { provide: Locale, useValue: SkLocale, multi: true },
* ]);
*
* const locales: Locale[] = injector.get(Locale);
* const localeNames: string[] = locals.map((l) => l.name);
* expect(localeNames).toEqual(['en', 'sk']);
* ```
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
*/

@@ -175,23 +117,15 @@ multi?: boolean;

/**
* Configures the {@link Injector} to return a value of another `useExisting` token.
* @whatItDoes Configures the {@link Injector} to return a value of another `useExisting` token.
* @howToUse
* ```
* const provider: ExistingProvider = {provide: 'someToken', useExisting: 'someOtherToken'};
* ```
*
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
* ```javascript
* class Greeting {
* salutation = 'Hello';
* }
*
* class FormalGreeting extends Greeting {
* salutation = 'Greetings';
* }
* {@example core/di/ts/provider_spec.ts region='ExistingProvider'}
*
* const injector = Injector.resolveAndCreate([
* FormalGreeting,
* {provide: Greeting, useExisting: FormalGreeting}
* ]);
*
* expect(injector.get(Greeting).name).toEqual('Hello');
* expect(injector.get(FormalGreeting).name).toEqual('Hello');
* expect(injector.get(Salutation).name).toBe(injector.get(Greeting));
* ```
* @stable

@@ -213,28 +147,4 @@ */

* ### Example
* ```javascript
* abstract class Locale {
* name: string;
* };
*
* @Injectable()
* class EnLocale extends Locale {
* name: 'en';
* };
*
* @Injectable()
* class SkLocale extends Locale {
* name: 'sk';
* };
*
* const injector = Injector.resolveAndCreate([
* EnLocale,
* SkLocale
* { provide: Locale, useExisting: EnLocale, multi: true },
* { provide: Locale, useExisting: SkLocale, multi: true },
* ]);
*
* const locales: Locale[] = injector.get(Locale);
* const localeNames: string[] = locals.map((l) => l.name);
* expect(localeNames).toEqual(['en', 'sk']);
* ```
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
*/

@@ -244,17 +154,21 @@ multi?: boolean;

/**
* Configures the {@link Injector} to return a value by invoking a `useFactory` function.
* @whatItDoes Configures the {@link Injector} to return a value by invoking a `useFactory`
* function.
* @howToUse
* ```
* function serviceFactory() { ... }
*
* const provider: FactoryProvider = {provide: 'someToken', useFactory: serviceFactory, deps: []};
* ```
*
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
* ```javascript
* const HASH = new OpaqueToken('hash');
*
* const injector = Injector.resolveAndCreate([
* {provide: Location, useValue: window.location},
* {provide: HASH, useFactory: (location: Location) => location.hash, deps: [Location]}
* ]);
* {@example core/di/ts/provider_spec.ts region='FactoryProvider'}
*
* Dependencies can also be marked as optional:
* {@example core/di/ts/provider_spec.ts region='FactoryProviderOptionalDeps'}
*
* // Assume location is: http://angular.io/#someLocation
* expect(injector.get(HASH)).toEqual('someLocation');
* ```
* @stable

@@ -282,20 +196,4 @@ */

* ### Example
* ```javascript
* class Locale {
* constructor(public name: string) {}
* };
* const PRIMARY = new OpequeToken('primary');
* const SECONDARY = new OpequeToken('secondary');
*
* const injector = Injector.resolveAndCreate([
* { provide: PRIMARY: useValue: 'en'},
* { provide: SECONDARY: useValue: 'sk'},
* { provide: Locale, useFactory: (n) => new Locale(n), deps: [PRIMARY], multi: true},
* { provide: Locale, useFactory: (n) => new Locale(n), deps: [SECONDARY], multi: true},
* ]);
*
* const locales: Locale[] = injector.get(Locale);
* const localeNames: string[] = locals.map((l) => l.name);
* expect(localeNames).toEqual(['en', 'sk']);
* ```
* {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
*/

@@ -305,40 +203,12 @@ multi?: boolean;

/**
* Describes how the {@link Injector} should be configured.
*
* @whatItDoes Describes how the {@link Injector} should be configured.
* @howToUse
* See {@link TypeProvider}, {@link ValueProvider}, {@link ClassProvider}, {@link ExistingProvider},
* {@link FactoryProvider}.
*
* ```javascript
* class Greeting {
* salutation = 'Hello';
* }
* @description
* For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* class FormalGreeting extends Greeting {
* salutation = 'Greetings';
* }
*
* abstract class Operation {
* apply(a,b): any;
* }
*
* class AddOperation extends Operation {
* apply(a,b) { return a+b; }
* }
*
*
* const injector = Injector.resolveAndCreate([
* FormalGreeting,
* {provide: String, useValue: 'Hello World!'},
* {provide: Greeting, useExisting: FormalGreeting},
* {provide: Operation, useClass: AddOperation},
* {provide: Number, useFactory: (op) =>op.apply(1,2), deps: [Operation] }
* ]);
*
* expect(injector.get(FormalGreeting).name).toEqual('Greetings');
* expect(injector.get(String).name).toEqual('Hello World!');
* expect(injector.get(Greeting).name).toBe(injector.get(FormalGreeting));
* expect(injector.get(Number).toEqual(3);
* ```
* @stable
*/
export declare type Provider = TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[];

@@ -1,5 +0,5 @@

export { ANALYZE_FOR_ENTRY_COMPONENTS, Attribute, ContentChild, ContentChildren, Query, ViewChild, ViewChildren } from './metadata/di';
export { Component, Directive, HostBinding, HostListener, Input, Output, Pipe } from './metadata/directives';
export { ANALYZE_FOR_ENTRY_COMPONENTS, Attribute, ContentChild, ContentChildDecorator, ContentChildren, ContentChildrenDecorator, Query, ViewChild, ViewChildDecorator, ViewChildren, ViewChildrenDecorator } from './metadata/di';
export { Component, ComponentDecorator, Directive, DirectiveDecorator, HostBinding, HostListener, Input, Output, Pipe } from './metadata/directives';
export { AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit } from './metadata/lifecycle_hooks';
export { CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NO_ERRORS_SCHEMA, NgModule, SchemaMetadata } from './metadata/ng_module';
export { ViewEncapsulation } from './metadata/view';

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./metadata/di","export":["ANALYZE_FOR_ENTRY_COMPONENTS","Attribute","ContentChild","ContentChildren","Query","ViewChild","ViewChildren"]},{"from":"./metadata/directives","export":["Component","Directive","HostBinding","HostListener","Input","Output","Pipe"]},{"from":"./metadata/lifecycle_hooks","export":["AfterContentChecked","AfterContentInit","AfterViewChecked","AfterViewInit","DoCheck","OnChanges","OnDestroy","OnInit"]},{"from":"./metadata/ng_module","export":["CUSTOM_ELEMENTS_SCHEMA","ModuleWithProviders","NO_ERRORS_SCHEMA","NgModule","SchemaMetadata"]},{"from":"./metadata/view","export":["ViewEncapsulation"]}]}
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./metadata/di","export":["ANALYZE_FOR_ENTRY_COMPONENTS","Attribute","ContentChild","ContentChildDecorator","ContentChildren","ContentChildrenDecorator","Query","ViewChild","ViewChildDecorator","ViewChildren","ViewChildrenDecorator"]},{"from":"./metadata/directives","export":["Component","ComponentDecorator","Directive","DirectiveDecorator","HostBinding","HostListener","Input","Output","Pipe"]},{"from":"./metadata/lifecycle_hooks","export":["AfterContentChecked","AfterContentInit","AfterViewChecked","AfterViewInit","DoCheck","OnChanges","OnDestroy","OnInit"]},{"from":"./metadata/ng_module","export":["CUSTOM_ELEMENTS_SCHEMA","ModuleWithProviders","NO_ERRORS_SCHEMA","NgModule","SchemaMetadata"]},{"from":"./metadata/view","export":["ViewEncapsulation"]}]}

@@ -98,4 +98,2 @@ import { OpaqueToken } from '../di/opaque_token';

* Type of the Attribute metadata.
*
* @stable
*/

@@ -125,4 +123,7 @@ export interface Attribute {

/**
* Base class for query metadata
* Base class for query metadata.
*
* See {@link ContentChildren}, {@link ContentChild}, {@link ViewChildren}, {@link ViewChild} for
* more information.
*
* @stable

@@ -135,2 +136,4 @@ */

*
* See {@link ContentChildren}.
*
* @stable

@@ -140,21 +143,31 @@ */

/**
* Configures a content query.
* @whatItDoes Configures a content query.
*
* @howToUse
*
* {@example core/di/ts/contentChildren/content_children_howto.ts region='HowTo'}
*
* @description
*
* You can use ContentChildren to get the {@link QueryList} of elements or directives from the
* content DOM. Any time a child element is added, removed, or moved, the query list will be
* updated,
* and the changes observable of the query list will emit a new value.
*
* Content queries are set before the `ngAfterContentInit` callback is called.
*
* ### Example
* **Metadata Properties**:
*
* ```
* @Directive({
* selector: 'someDir'
* })
* class SomeDir {
* @ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>;
* * **selector** - the directive type or the name used for querying.
* * **descendants** - include only direct children or all descendants.
* * **read** - read a different token from the queried elements.
*
* ngAfterContentInit() {
* // contentChildren is set
* }
* }
* ```
* Let's look at an example:
*
* {@example core/di/ts/contentChildren/content_children_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable
* @Annotation
*/

@@ -174,2 +187,3 @@ (selector: Type<any> | Function | string, {descendants, read}?: {

* @stable
* @Annotation
*/

@@ -180,4 +194,4 @@ export declare type ContentChildren = Query;

*
* @stable
* @Annotation
* @stable
* @Annotation
*/

@@ -188,2 +202,3 @@ export declare const ContentChildren: ContentChildrenDecorator;

*
*
* @stable

@@ -193,29 +208,3 @@ */

/**
* Configures a content query.
*
* Content queries are set before the `ngAfterContentInit` callback is called.
*
* ### Example
*
* ```
* @Directive({
* selector: 'someDir'
* })
* class SomeDir {
* @ContentChild(ChildDirective) contentChild;
* @ContentChild('container_ref') containerChild
*
* ngAfterContentInit() {
* // contentChild is set
* // containerChild is set
* }
* }
* ```
*
* ```html
* <container #container_ref>
* <item>a</item>
* <item>b</item>
* </container>
* ```
* @docsNotRequired
*/

@@ -232,2 +221,4 @@ (selector: Type<any> | Function | string, {read}?: {

*
* See {@link ContentChild}.
*
* @stable

@@ -237,4 +228,27 @@ */

/**
* ContentChild decorator and metadata.
* @whatItDoes Configures a content query.
*
* @howToUse
*
* {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
*
* @description
*
* You can use ContentChild to get the first element or the directive matching the selector from the
* content DOM. If the content DOM changes, and a new child matches the selector,
* the property will be updated.
*
* Content queries are set before the `ngAfterContentInit` callback is called.
*
* **Metadata Properties**:
*
* * **selector** - the directive type or the name used for querying.
* * **read** - read a different token from the queried element.
*
* Let's look at an example:
*
* {@example core/di/ts/contentChild/content_child_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable

@@ -247,2 +261,4 @@ * @Annotation

*
* See {@ViewChildren}.
*
* @stable

@@ -252,78 +268,3 @@ */

/**
* Declares a list of child element references.
*
* Angular automatically updates the list when the DOM is updated.
*
* `ViewChildren` takes an argument to select elements.
*
* - If the argument is a type, directives or components with the type will be bound.
*
* - If the argument is a string, the string is interpreted as a list of comma-separated selectors.
* For each selector, an element containing the matching template variable (e.g. `#child`) will be
* bound.
*
* View children are set before the `ngAfterViewInit` callback is called.
*
* ### Example
*
* With type selector:
*
* ```
* @Component({
* selector: 'child-cmp',
* template: '<p>child</p>'
* })
* class ChildCmp {
* doSomething() {}
* }
*
* @Component({
* selector: 'some-cmp',
* template: `
* <child-cmp></child-cmp>
* <child-cmp></child-cmp>
* <child-cmp></child-cmp>
* `,
* directives: [ChildCmp]
* })
* class SomeCmp {
* @ViewChildren(ChildCmp) children:QueryList<ChildCmp>;
*
* ngAfterViewInit() {
* // children are set
* this.children.toArray().forEach((child)=>child.doSomething());
* }
* }
* ```
*
* With string selector:
*
* ```
* @Component({
* selector: 'child-cmp',
* template: '<p>child</p>'
* })
* class ChildCmp {
* doSomething() {}
* }
*
* @Component({
* selector: 'some-cmp',
* template: `
* <child-cmp #child1></child-cmp>
* <child-cmp #child2></child-cmp>
* <child-cmp #child3></child-cmp>
* `,
* directives: [ChildCmp]
* })
* class SomeCmp {
* @ViewChildren('child1,child2,child3') children:QueryList<ChildCmp>;
*
* ngAfterViewInit() {
* // children are set
* this.children.toArray().forEach((child)=>child.doSomething());
* }
* }
* ```
* @stable
* @docsNotRequired
*/ (selector: Type<any> | Function | string, {read}?: {

@@ -343,4 +284,27 @@ read?: any;

/**
* ViewChildren decorator and metadata.
* @whatItDoes Configures a view query.
*
* @howToUse
*
* {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
*
* @description
*
* You can use ViewChildren to get the {@link QueryList} of elements or directives from the
* view DOM. Any time a child element is added, removed, or moved, the query list will be updated,
* and the changes observable of the query list will emit a new value.
*
* View queries are set before the `ngAfterViewInit` callback is called.
*
* **Metadata Properties**:
*
* * **selector** - the directive type or the name used for querying.
* * **read** - read a different token from the queried elements.
*
* Let's look at an example:
*
* {@example core/di/ts/viewChildren/view_children_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable

@@ -353,2 +317,4 @@ * @Annotation

*
* See {@link ViewChild}
*
* @stable

@@ -358,72 +324,31 @@ */

/**
*
* Declares a reference of child element.
*
* `ViewChildren` takes an argument to select elements.
*
* - If the argument is a type, a directive or a component with the type will be bound.
*
* If the argument is a string, the string is interpreted as a selector. An element containing the
* matching template variable (e.g. `#child`) will be bound.
*
* In either case, `@ViewChild()` assigns the first (looking from above) element if there are
multiple matches.
*
* View child is set before the `ngAfterViewInit` callback is called.
*
* ### Example
*
* With type selector:
*
* ```
* @Component({
* selector: 'child-cmp',
* template: '<p>child</p>'
* })
* class ChildCmp {
* doSomething() {}
* }
*
* @Component({
* selector: 'some-cmp',
* template: '<child-cmp></child-cmp>',
* directives: [ChildCmp]
* })
* class SomeCmp {
* @ViewChild(ChildCmp) child:ChildCmp;
*
* ngAfterViewInit() {
* // child is set
* this.child.doSomething();
* }
* }
* ```
*
* With string selector:
*
* ```
* @Component({
* selector: 'child-cmp',
* template: '<p>child</p>'
* })
* class ChildCmp {
* doSomething() {}
* }
*
* @Component({
* selector: 'some-cmp',
* template: '<child-cmp #child></child-cmp>',
* directives: [ChildCmp]
* })
* class SomeCmp {
* @ViewChild('child') child:ChildCmp;
*
* ngAfterViewInit() {
* // child is set
* this.child.doSomething();
* }
* }
* ```
* @stable
*/ (selector: Type<any> | Function | string, {read}?: {
* @whatItDoes Configures a view query.
*
* @howToUse
*
* {@example core/di/ts/viewChild/view_child_howto.ts region='HowTo'}
*
* @description
*
* You can use ViewChild to get the first element or the directive matching the selector from the
* view DOM. If the view DOM changes, and a new child matches the selector,
* the property will be updated.
*
* View queries are set before the `ngAfterViewInit` callback is called.
*
* **Metadata Properties**:
*
* * **selector** - the directive type or the name used for querying.
* * **read** - read a different token from the queried elements.
*
* Let's look at an example!!!!:
*
* {@example core/di/ts/viewChild/view_child_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable
* @Annotation
*/
(selector: Type<any> | Function | string, {read}?: {
read?: any;

@@ -430,0 +355,0 @@ }): any;

@@ -53,4 +53,7 @@ /**

/**
* Base class for query metadata
* Base class for query metadata.
*
* See {@link ContentChildren}, {@link ContentChild}, {@link ViewChildren}, {@link ViewChild} for
* more information.
*
* @stable

@@ -66,4 +69,4 @@ */

*
* @stable
* @Annotation
* @stable
* @Annotation
*/

@@ -75,4 +78,27 @@ export var ContentChildren = makePropDecorator('ContentChildren', [

/**
* ContentChild decorator and metadata.
* @whatItDoes Configures a content query.
*
* @howToUse
*
* {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
*
* @description
*
* You can use ContentChild to get the first element or the directive matching the selector from the
* content DOM. If the content DOM changes, and a new child matches the selector,
* the property will be updated.
*
* Content queries are set before the `ngAfterContentInit` callback is called.
*
* **Metadata Properties**:
*
* * **selector** - the directive type or the name used for querying.
* * **read** - read a different token from the queried element.
*
* Let's look at an example:
*
* {@example core/di/ts/contentChild/content_child_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable

@@ -90,4 +116,27 @@ * @Annotation

/**
* ViewChildren decorator and metadata.
* @whatItDoes Configures a view query.
*
* @howToUse
*
* {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
*
* @description
*
* You can use ViewChildren to get the {@link QueryList} of elements or directives from the
* view DOM. Any time a child element is added, removed, or moved, the query list will be updated,
* and the changes observable of the query list will emit a new value.
*
* View queries are set before the `ngAfterViewInit` callback is called.
*
* **Metadata Properties**:
*
* * **selector** - the directive type or the name used for querying.
* * **read** - read a different token from the queried elements.
*
* Let's look at an example:
*
* {@example core/di/ts/viewChildren/view_children_example.ts region='Component'}
*
* **npm package**: `@angular/core`
*
* @stable

@@ -94,0 +143,0 @@ * @Annotation

@@ -21,416 +21,47 @@ /**

/**
* Directives allow you to attach behavior to elements in the DOM.
* @whatItDoes Marks a class as an Angular directive and collects directive configuration
* metadata.
*
* {@link Directive}s with an embedded view are called {@link Component}s.
* @howToUse
*
* A directive consists of a single directive annotation and a controller class. When the
* directive's `selector` matches
* elements in the DOM, the following steps occur:
*
* 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor
* arguments.
* 2. Angular instantiates directives for each matched element using `ElementInjector` in a
* depth-first order,
* as declared in the HTML.
*
* ## Understanding How Injection Works
*
* There are three stages of injection resolution.
* - *Pre-existing Injectors*:
* - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if
* the dependency was
* specified as `@Optional`, returns `null`.
* - The platform injector resolves browser singleton resources, such as: cookies, title,
* location, and others.
* - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow
* the same parent-child hierarchy
* as the component instances in the DOM.
* - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each
* element has an `ElementInjector`
* which follow the same parent-child hierarchy as the DOM elements themselves.
*
* When a template is instantiated, it also must instantiate the corresponding directives in a
* depth-first order. The
* current `ElementInjector` resolves the constructor dependencies for each directive.
*
* Angular then resolves dependencies as follows, according to the order in which they appear in
* the
* {@link Component}:
*
* 1. Dependencies on the current element
* 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM
* boundary
* 3. Dependencies on component injectors and their parents until it encounters the root component
* 4. Dependencies on pre-existing injectors
*
*
* The `ElementInjector` can inject other directives, element-specific special objects, or it can
* delegate to the parent
* injector.
*
* To inject other directives, declare the constructor parameter as:
* - `directive:DirectiveType`: a directive on the current element only
* - `@Host() directive:DirectiveType`: any directive that matches the type between the current
* element and the
* Shadow DOM root.
* - `@Query(DirectiveType) query:QueryList<DirectiveType>`: A live collection of direct child
* directives.
* - `@QueryDescendants(DirectiveType) query:QueryList<DirectiveType>`: A live collection of any
* child directives.
*
* To inject element-specific special objects, declare the constructor parameter as:
* - `element: ElementRef` to obtain a reference to logical element in the view.
* - `viewContainer: ViewContainerRef` to control child template instantiation, for
* {@link Directive} directives only
* - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
*
* ### Example
*
* The following example demonstrates how dependency injection resolves constructor arguments in
* practice.
*
*
* Assume this HTML template:
*
* ```
* <div dependency="1">
* <div dependency="2">
* <div dependency="3" my-directive>
* <div dependency="4">
* <div dependency="5"></div>
* </div>
* <div dependency="6"></div>
* </div>
* </div>
* </div>
* ```
* import {Directive} from '@angular/core';
*
* With the following `dependency` decorator and `SomeService` injectable class.
*
* ```
* @Injectable()
* class SomeService {
* }
*
* @Directive({
* selector: '[dependency]',
* inputs: [
* 'id: dependency'
* ]
* selector: 'my-directive',
* })
* class Dependency {
* id:string;
* export class MyDirective {
* }
* ```
*
* Let's step through the different ways in which `MyDirective` could be declared...
* @description
*
*
* ### No injection
*
* Here the constructor is declared with no arguments, therefore nothing is injected into
* `MyDirective`.
*
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor() {
* }
* }
* ```
*
* This directive would be instantiated with no dependencies.
*
*
* ### Component-level injection
*
* Directives can inject any injectable instance from the closest component injector or any of its
* parents.
*
* Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type
* from the parent
* component's injector.
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(someService: SomeService) {
* }
* }
* ```
*
* This directive would be instantiated with a dependency on `SomeService`.
*
*
* ### Injecting a directive from the current element
*
* Directives can inject other directives declared on the current element.
*
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(dependency: Dependency) {
* expect(dependency.id).toEqual(3);
* }
* }
* ```
* This directive would be instantiated with `Dependency` declared at the same element, in this
* case
* `dependency="3"`.
*
* ### Injecting a directive from any ancestor elements
*
* Directives can inject other directives declared on any ancestor element (in the current Shadow
* DOM), i.e. on the current element, the
* parent element, or its parents.
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(@Host() dependency: Dependency) {
* expect(dependency.id).toEqual(2);
* }
* }
* ```
*
* `@Host` checks the current element, the parent, as well as its parents recursively. If
* `dependency="2"` didn't
* exist on the direct parent, this injection would
* have returned
* `dependency="1"`.
*
*
* ### Injecting a live collection of direct child directives
*
*
* A directive can also query for other child directives. Since parent directives are instantiated
* before child directives, a directive can't simply inject the list of child directives. Instead,
* the directive injects a {@link QueryList}, which updates its contents as children are added,
* removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ngFor`, an
* `ngIf`, or an `ngSwitch`.
*
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(@Query(Dependency) dependencies:QueryList<Dependency>) {
* }
* }
* ```
*
* This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and
* `Dependency` 6. Here, `Dependency` 5 would not be included, because it is not a direct child.
*
* ### Injecting a live collection of descendant directives
*
* By passing the descendant flag to `@Query` above, we can include the children of the child
* elements.
*
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList<Dependency>) {
* }
* }
* ```
*
* This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6.
*
* ### Optional injection
*
* The normal behavior of directives is to return an error when a specified dependency cannot be
* resolved. If you
* would like to inject `null` on unresolved dependency instead, you can annotate that dependency
* with `@Optional()`.
* This explicitly permits the author of a template to treat some of the surrounding directives as
* optional.
*
* ```
* @Directive({ selector: '[my-directive]' })
* class MyDirective {
* constructor(@Optional() dependency:Dependency) {
* }
* }
* ```
*
* This directive would be instantiated with a `Dependency` directive found on the current
* element.
* If none can be
* found, the injector supplies `null` instead of throwing an error.
*
* ### Example
*
* Here we use a decorator directive to simply define basic tool-tip behavior.
*
* ```
* @Directive({
* selector: '[tooltip]',
* inputs: [
* 'text: tooltip'
* ],
* host: {
* '(mouseenter)': 'onMouseEnter()',
* '(mouseleave)': 'onMouseLeave()'
* }
* })
* class Tooltip{
* text:string;
* overlay:Overlay; // NOT YET IMPLEMENTED
* overlayManager:OverlayManager; // NOT YET IMPLEMENTED
*
* constructor(overlayManager:OverlayManager) {
* this.overlay = overlay;
* }
*
* onMouseEnter() {
* // exact signature to be determined
* this.overlay = this.overlayManager.open(text, ...);
* }
*
* onMouseLeave() {
* this.overlay.close();
* this.overlay = null;
* }
* }
* ```
* In our HTML template, we can then add this behavior to a `<div>` or any other element with the
* `tooltip` selector,
* like so:
*
* ```
* <div tooltip="some text here"></div>
* ```
*
* Directives can also control the instantiation, destruction, and positioning of inline template
* elements:
*
* A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at
* Directive decorator allows you to mark a class as an Angular directive and provide additional
* metadata that determines how the directive should be processed, instantiated and used at
* runtime.
* The {@link ViewContainerRef} is created as a result of `<template>` element, and represents a
* location in the current view
* where these actions are performed.
*
* Views are always created as children of the current {@link Component}, and as siblings
* of
* the
* `<template>` element. Thus a
* directive in a child view cannot inject the directive that created it.
* Directives allow you to attach behavior to elements in the DOM..
*
* Since directives that create views via ViewContainers are common in Angular, and using the full
* `<template>` element syntax is wordy, Angular
* also supports a shorthand notation: `<li *foo="bar">` and `<li template="foo: bar">` are
* equivalent.
* A directive must belong to an NgModule in order for it to be usable
* by another directive, component, or application. To specify that a directive is a member of an
* NgModule,
* you should list it in the `declarations` field of that NgModule.
*
* Thus,
* In addition to the metadata configuration specified via the Directive decorator,
* directives can control their runtime behavior by implementing various Life-Cycle hooks.
*
* ```
* <ul>
* <li *foo="bar" title="text"></li>
* </ul>
* ```
* **Metadata Properties:**
*
* Expands in use to:
* * **exportAs** - name under which the component instance is exported in a template
* * **host** - map of class property to host element bindings for events, properties and
* attributes
* * **inputs** - list of class property names to data-bind as component inputs
* * **outputs** - list of class property names that expose output events that others can
* subscribe to
* * **providers** - list of providers available to this component and its children
* * **queries** - configure queries that can be injected into the component
* * **selector** - css selector that identifies this component in a template
*
* ```
* <ul>
* <template [foo]="bar">
* <li title="text"></li>
* </template>
* </ul>
* ```
*
* Notice that although the shorthand places `*foo="bar"` within the `<li>` element, the binding
* for
* the directive
* controller is correctly instantiated on the `<template>` element rather than the `<li>`
* element.
*
* ## Lifecycle hooks
*
* When the directive class implements some {@linkDocs guide/lifecycle-hooks} the
* callbacks are called by the change detection at defined points in time during the life of the
* directive.
*
* ### Example
*
* Let's suppose we want to implement the `unless` behavior, to conditionally include a template.
*
* Here is a simple directive that triggers on an `unless` selector:
*
* ```
* @Directive({
* selector: '[unless]',
* inputs: ['unless']
* })
* export class Unless {
* viewContainer: ViewContainerRef;
* templateRef: TemplateRef;
* prevCondition: boolean;
*
* constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef) {
* this.viewContainer = viewContainer;
* this.templateRef = templateRef;
* this.prevCondition = null;
* }
*
* set unless(newCondition) {
* if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) {
* this.prevCondition = true;
* this.viewContainer.clear();
* } else if (!newCondition && (isBlank(this.prevCondition) || this.prevCondition)) {
* this.prevCondition = false;
* this.viewContainer.create(this.templateRef);
* }
* }
* }
* ```
*
* We can then use this `unless` selector in a template:
* ```
* <ul>
* <li *unless="expr"></li>
* </ul>
* ```
*
* Once the directive instantiates the child view, the shorthand notation for the template expands
* and the result is:
*
* ```
* <ul>
* <template [unless]="exp">
* <li></li>
* </template>
* <li></li>
* </ul>
* ```
*
* Note also that although the `<li></li>` template still exists inside the
* `<template></template>`,
* the instantiated
* view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
*
* ### Example as TypeScript Decorator
*
* {@example core/ts/metadata/metadata.ts region='directive'}
*
* ### Example as ES5 DSL
*
* ```
* var MyDirective = ng
* .Directive({...})
* .Class({
* constructor: function() {
* ...
* }
* })
* ```
*
* ### Example as ES5 annotation
*
* ```
* var MyDirective = function() {
* ...
* };
*
* MyDirective.annotations = [
* new ng.Directive({...})
* ]
* ```
* @stable
* @Annotation
*/

@@ -772,54 +403,56 @@ (obj: Directive): TypeDecorator;

/**
* Declare reusable UI building blocks for an application.
* @whatItDoes Marks a class as an Angular component and collects component configuration
* metadata.
*
* Each Angular component requires a single `@Component` annotation. The
* `@Component`
* annotation specifies when a component is instantiated, and which properties and hostListeners
* it
* binds to.
* @howToUse
*
* When a component is instantiated, Angular
* - creates a shadow DOM for the component.
* - loads the selected template into the shadow DOM.
* - creates all the injectable objects configured with `providers` and `viewProviders`.
* {@example core/ts/metadata/metadata.ts region='component'}
*
* All template expressions and statements are then evaluated against the component instance.
* @description
* Component decorator allows you to mark a class as an Angular component and provide additional
* metadata that determines how the component should be processed, instantiated and used at
* runtime.
*
* ## Lifecycle hooks
* Components are the most basic building block of an UI in an Angular application.
* An Angular application is a tree of Angular components.
* Angular components are a subset of directives. Unlike directives, components always have
* a template and only one component can be instantiated per an element in a template.
*
* When the component class implements some {@linkDocs guide/lifecycle-hooks} the
* callbacks are called by the change detection at defined points in time during the life of the
* component.
* A component must belong to an NgModule in order for it to be usable
* by another component or application. To specify that a component is a member of an NgModule,
* you should list it in the `declarations` field of that NgModule.
*
* ### Example
* In addition to the metadata configuration specified via the Component decorator,
* components can control their runtime behavior by implementing various Life-Cycle hooks.
*
* {@example core/ts/metadata/metadata.ts region='component'}
* **Metadata Properties:**
*
* ### Example as TypeScript Decorator
* * **animations** - list of animations of this component
* * **changeDetection** - change detection strategy used by this component
* * **encapsulation** - style encapsulation strategy used by this component
* * **entryComponents** - list of components that are dynamically inserted into the view of this
* component
* * **exportAs** - name under which the component instance is exported in a template
* * **host** - map of class property to host element bindings for events, properties and
* attributes
* * **inputs** - list of class property names to data-bind as component inputs
* * **interpolation** - custom interpolation markers used in this component's template
* * **moduleId** - ES/CommonJS module id of the file in which this component is defined
* * **outputs** - list of class property names that expose output events that others can
* subscribe to
* * **providers** - list of providers available to this component and its children
* * **queries** - configure queries that can be injected into the component
* * **selector** - css selector that identifies this component in a template
* * **styleUrls** - list of urls to stylesheets to be applied to this component's view
* * **styles** - inline-defined styles to be applied to this component's view
* * **template** - inline-defined template for the view
* * **templateUrl** - url to an external file containing a template for the view
* * **viewProviders** - list of providers available to this component and its view children
*
* ### Example
*
* {@example core/ts/metadata/metadata.ts region='component'}
*
* ### Example as ES5 DSL
*
* ```
* var MyComponent = ng
* .Component({...})
* .Class({
* constructor: function() {
* ...
* }
* })
* ```
*
* ### Example as ES5 annotation
*
* ```
* var MyComponent = function() {
* ...
* };
*
* MyComponent.annotations = [
* new ng.Component({...})
* ]
* ```
* @stable
* @Annotation
*/

@@ -909,5 +542,3 @@ (obj: Component): TypeDecorator;

*
* NOTE: Only one of `templateUrl` or `template` can be defined per View.
*
* <!-- TODO: what's the url relative to? -->
*Only one of `templateUrl` or `template` can be defined per View.
*/

@@ -918,3 +549,3 @@ templateUrl?: string;

*
* NOTE: Only one of `templateUrl` or `template` can be defined per View.
* Only one of `templateUrl` or `template` can be defined per Component.
*/

@@ -924,4 +555,2 @@ template?: string;

* Specifies stylesheet URLs for an Angular component.
*
* <!-- TODO: what's the url relative to? -->
*/

@@ -928,0 +557,0 @@ styleUrls?: string[];

@@ -32,47 +32,13 @@ /**

/**
* Lifecycle hooks are guaranteed to be called in the following order:
* - `OnChanges` (if any bindings have changed),
* - `OnInit` (after the first check only),
* - `DoCheck`,
* - `AfterContentInit`,
* - `AfterContentChecked`,
* - `AfterViewInit`,
* - `AfterViewChecked`,
* - `OnDestroy` (at the very end before destruction)
*/
/**
* Implement this interface to get notified when any data-bound property of your directive changes.
* @whatItDoes Lifecycle hook that is called when any data-bound property of a directive changes.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
*
* @description
* `ngOnChanges` is called right after the data-bound properties have been checked and before view
* and content children are checked if at least one of them has changed.
* The `changes` parameter contains the changed properties.
*
* The `changes` parameter contains an entry for each of the changed data-bound property. The key is
* the property name and the value is an instance of {@link SimpleChange}.
* See {@linkDocs guide/lifecycle-hooks#onchanges "Lifecycle Hooks Guide"}.
*
* ### Example ([live example](http://plnkr.co/edit/AHrB6opLqHDBPkt4KpdT?p=preview)):
*
* ```typescript
* @Component({
* selector: 'my-cmp',
* template: `<p>myProp = {{myProp}}</p>`
* })
* class MyComponent implements OnChanges {
* @Input() myProp: any;
*
* ngOnChanges(changes: SimpleChanges) {
* console.log('ngOnChanges - myProp = ' + changes['myProp'].currentValue);
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="value = value + 1">Change MyComponent</button>
* <my-cmp [my-prop]="value"></my-cmp>`,
* directives: [MyComponent]
* })
* export class App {
* value = 0;
* }
* ```
* @stable

@@ -84,5 +50,8 @@ */

/**
* Implement this interface to execute custom initialization logic after your directive's
* data-bound properties have been initialized.
* @whatItDoes Lifecycle hook that is called after data-bound properties of a directive are
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnInit'}
*
* @description
* `ngOnInit` is called right after the directive's data-bound properties have been checked for the

@@ -92,32 +61,4 @@ * first time, and before any of its children have been checked. It is invoked only once when the

*
* ### Example ([live example](http://plnkr.co/edit/1MBypRryXd64v4pV03Yn?p=preview))
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({
* selector: 'my-cmp',
* template: `<p>my-component</p>`
* })
* class MyComponent implements OnInit, OnDestroy {
* ngOnInit() {
* console.log('ngOnInit');
* }
*
* ngOnDestroy() {
* console.log('ngOnDestroy');
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="hasChild = !hasChild">
* {{hasChild ? 'Destroy' : 'Create'}} MyComponent
* </button>
* <my-cmp *ngIf="hasChild"></my-cmp>`,
* directives: [MyComponent, NgIf]
* })
* export class App {
* hasChild = true;
* }
* ```
* @stable

@@ -129,66 +70,20 @@ */

/**
* Implement this interface to supplement the default change detection algorithm in your directive.
* @whatItDoes Lifecycle hook that is called when Angular dirty checks a directive.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
*
* @description
* `ngDoCheck` gets called to check the changes in the directives in addition to the default
* algorithm.
* algorithm. The default change detection algorithm looks for differences by comparing
* bound-property values by reference across change detection runs.
*
* The default change detection algorithm looks for differences by comparing bound-property values
* by reference across change detection runs.
*
* Note that a directive typically should not use both `DoCheck` and {@link OnChanges} to respond to
* changes on the same input. `ngOnChanges` will continue to be called when the default change
* detector
* detects changes, so it is usually unnecessary to respond to changes on the same input in both
* hooks.
* Reaction to the changes have to be handled from within the `ngDoCheck` callback.
* changes on the same input, as `ngOnChanges` will continue to be called when the default change
* detector detects changes.
*
* You can use {@link KeyValueDiffers} and {@link IterableDiffers} to help add your custom check
* mechanisms.
* See {@link KeyValueDiffers} and {@link IterableDiffers} for implementing custom dirty checking
* for collections.
*
* ### Example ([live demo](http://plnkr.co/edit/QpnIlF0CR2i5bcYbHEUJ?p=preview))
* See {@linkDocs guide/lifecycle-hooks#docheck "Lifecycle Hooks Guide"}.
*
* In the following example `ngDoCheck` uses an {@link IterableDiffers} to detect the updates to the
* array `list`:
*
* ```typescript
* @Component({
* selector: 'custom-check',
* template: `
* <p>Changes:</p>
* <ul>
* <li *ngFor="let line of logs">{{line}}</li>
* </ul>`,
* directives: [NgFor]
* })
* class CustomCheckComponent implements DoCheck {
* @Input() list: any[];
* differ: any;
* logs = [];
*
* constructor(differs: IterableDiffers) {
* this.differ = differs.find([]).create(null);
* }
*
* ngDoCheck() {
* var changes = this.differ.diff(this.list);
*
* if (changes) {
* changes.forEachAddedItem(r => this.logs.push('added ' + r.item));
* changes.forEachRemovedItem(r => this.logs.push('removed ' + r.item))
* }
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="list.push(list.length)">Push</button>
* <button (click)="list.pop()">Pop</button>
* <custom-check [list]="list"></custom-check>`,
* directives: [CustomCheckComponent]
* })
* export class App {
* list = [];
* }
* ```
* @stable

@@ -200,87 +95,12 @@ */

/**
* Implement this interface to get notified when your directive is destroyed.
* @whatItDoes Lifecycle hook that is called when a directive or pipe is destroyed.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
*
* @description
* `ngOnDestroy` callback is typically used for any custom cleanup that needs to occur when the
* instance is destroyed
* instance is destroyed.
*
* ### Example ([live example](http://plnkr.co/edit/1MBypRryXd64v4pV03Yn?p=preview))
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* ```typesript
* @Component({
* selector: 'my-cmp',
* template: `<p>my-component</p>`
* })
* class MyComponent implements OnInit, OnDestroy {
* ngOnInit() {
* console.log('ngOnInit');
* }
*
* ngOnDestroy() {
* console.log('ngOnDestroy');
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="hasChild = !hasChild">
* {{hasChild ? 'Destroy' : 'Create'}} MyComponent
* </button>
* <my-cmp *ngIf="hasChild"></my-cmp>`,
* directives: [MyComponent, NgIf]
* })
* export class App {
* hasChild = true;
* }
* ```
*
*
* To create a stateful Pipe, you should implement this interface and set the `pure`
* parameter to `false` in the {@link Pipe}.
*
* A stateful pipe may produce different output, given the same input. It is
* likely that a stateful pipe may contain state that should be cleaned up when
* a binding is destroyed. For example, a subscription to a stream of data may need to
* be disposed, or an interval may need to be cleared.
*
* ### Example ([live demo](http://plnkr.co/edit/i8pm5brO4sPaLxBx56MR?p=preview))
*
* In this example, a pipe is created to countdown its input value, updating it every
* 50ms. Because it maintains an internal interval, it automatically clears
* the interval when the binding is destroyed or the countdown completes.
*
* ```
* import {OnDestroy, Pipe, PipeTransform} from '@angular/core'
* @Pipe({name: 'countdown', pure: false})
* class CountDown implements PipeTransform, OnDestroy {
* remainingTime:Number;
* interval:SetInterval;
* ngOnDestroy() {
* if (this.interval) {
* clearInterval(this.interval);
* }
* }
* transform(value: any, args: any[] = []) {
* if (!parseInt(value, 10)) return null;
* if (typeof this.remainingTime !== 'number') {
* this.remainingTime = parseInt(value, 10);
* }
* if (!this.interval) {
* this.interval = setInterval(() => {
* this.remainingTime-=50;
* if (this.remainingTime <= 0) {
* this.remainingTime = 0;
* clearInterval(this.interval);
* delete this.interval;
* }
* }, 50);
* }
* return this.remainingTime;
* }
* }
* ```
*
* Invoking `{{ 10000 | countdown }}` would cause the value to be decremented by 50,
* every 50ms, until it reaches 0.
*
* @stable

@@ -292,49 +112,11 @@ */

/**
* Implement this interface to get notified when your directive's content has been fully
*
* @whatItDoes Lifecycle hook that is called after a directive's content has been fully
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
*
* ### Example ([live demo](http://plnkr.co/edit/plamXUpsLQbIXpViZhUO?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({
* selector: 'child-cmp',
* template: `{{where}} child`
* })
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `<ng-content></ng-content>`
* })
* class ParentComponent implements AfterContentInit {
* @ContentChild(ChildComponent) contentChild: ChildComponent;
*
* constructor() {
* // contentChild is not initialized yet
* console.log(this.getMessage(this.contentChild));
* }
*
* ngAfterContentInit() {
* // contentChild is updated after the content has been checked
* console.log('AfterContentInit: ' + this.getMessage(this.contentChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <parent-cmp>
* <child-cmp where="content"></child-cmp>
* </parent-cmp>`,
* directives: [ParentComponent, ChildComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -346,44 +128,9 @@ */

/**
* Implement this interface to get notified after every check of your directive's content.
* @whatItDoes Lifecycle hook that is called after every check of a directive's content.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
*
* ### Example ([live demo](http://plnkr.co/edit/tGdrytNEKQnecIPkD7NU?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({selector: 'parent-cmp', template: `<ng-content></ng-content>`})
* class ParentComponent implements AfterContentChecked {
* @ContentChild(ChildComponent) contentChild: ChildComponent;
*
* constructor() {
* // contentChild is not initialized yet
* console.log(this.getMessage(this.contentChild));
* }
*
* ngAfterContentChecked() {
* // contentChild is updated after the content has been checked
* console.log('AfterContentChecked: ' + this.getMessage(this.contentChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <parent-cmp>
* <button (click)="hasContent = !hasContent">Toggle content child</button>
* <child-cmp *ngIf="hasContent" where="content"></child-cmp>
* </parent-cmp>`,
* directives: [NgIf, ParentComponent, ChildComponent]
* })
* export class App {
* hasContent = true;
* }
* ```
* @stable

@@ -395,43 +142,10 @@ */

/**
* Implement this interface to get notified when your component's view has been fully initialized.
* @whatItDoes Lifecycle hook that is called after a component's view has been fully
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
*
* ### Example ([live demo](http://plnkr.co/edit/LhTKVMEM0fkJgyp4CI1W?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `<child-cmp where="view"></child-cmp>`,
* directives: [ChildComponent]
* })
* class ParentComponent implements AfterViewInit {
* @ViewChild(ChildComponent) viewChild: ChildComponent;
*
* constructor() {
* // viewChild is not initialized yet
* console.log(this.getMessage(this.viewChild));
* }
*
* ngAfterViewInit() {
* // viewChild is updated after the view has been initialized
* console.log('ngAfterViewInit: ' + this.getMessage(this.viewChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `<parent-cmp></parent-cmp>`,
* directives: [ParentComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -443,46 +157,9 @@ */

/**
* Implement this interface to get notified after every check of your component's view.
* @whatItDoes Lifecycle hook that is called after every check of a component's view.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
*
* ### Example ([live demo](http://plnkr.co/edit/0qDGHcPQkc25CXhTNzKU?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `
* <button (click)="showView = !showView">Toggle view child</button>
* <child-cmp *ngIf="showView" where="view"></child-cmp>`,
* directives: [NgIf, ChildComponent]
* })
* class ParentComponent implements AfterViewChecked {
* @ViewChild(ChildComponent) viewChild: ChildComponent;
* showView = true;
*
* constructor() {
* // viewChild is not initialized yet
* console.log(this.getMessage(this.viewChild));
* }
*
* ngAfterViewChecked() {
* // viewChild is updated after the view has been checked
* console.log('AfterViewChecked: ' + this.getMessage(this.viewChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `<parent-cmp></parent-cmp>`,
* directives: [ParentComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -489,0 +166,0 @@ */

@@ -28,47 +28,13 @@ /**

/**
* Lifecycle hooks are guaranteed to be called in the following order:
* - `OnChanges` (if any bindings have changed),
* - `OnInit` (after the first check only),
* - `DoCheck`,
* - `AfterContentInit`,
* - `AfterContentChecked`,
* - `AfterViewInit`,
* - `AfterViewChecked`,
* - `OnDestroy` (at the very end before destruction)
*/
/**
* Implement this interface to get notified when any data-bound property of your directive changes.
* @whatItDoes Lifecycle hook that is called when any data-bound property of a directive changes.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
*
* @description
* `ngOnChanges` is called right after the data-bound properties have been checked and before view
* and content children are checked if at least one of them has changed.
* The `changes` parameter contains the changed properties.
*
* The `changes` parameter contains an entry for each of the changed data-bound property. The key is
* the property name and the value is an instance of {@link SimpleChange}.
* See {@linkDocs guide/lifecycle-hooks#onchanges "Lifecycle Hooks Guide"}.
*
* ### Example ([live example](http://plnkr.co/edit/AHrB6opLqHDBPkt4KpdT?p=preview)):
*
* ```typescript
* @Component({
* selector: 'my-cmp',
* template: `<p>myProp = {{myProp}}</p>`
* })
* class MyComponent implements OnChanges {
* @Input() myProp: any;
*
* ngOnChanges(changes: SimpleChanges) {
* console.log('ngOnChanges - myProp = ' + changes['myProp'].currentValue);
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="value = value + 1">Change MyComponent</button>
* <my-cmp [my-prop]="value"></my-cmp>`,
* directives: [MyComponent]
* })
* export class App {
* value = 0;
* }
* ```
* @stable

@@ -82,5 +48,8 @@ */

/**
* Implement this interface to execute custom initialization logic after your directive's
* data-bound properties have been initialized.
* @whatItDoes Lifecycle hook that is called after data-bound properties of a directive are
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnInit'}
*
* @description
* `ngOnInit` is called right after the directive's data-bound properties have been checked for the

@@ -90,32 +59,4 @@ * first time, and before any of its children have been checked. It is invoked only once when the

*
* ### Example ([live example](http://plnkr.co/edit/1MBypRryXd64v4pV03Yn?p=preview))
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({
* selector: 'my-cmp',
* template: `<p>my-component</p>`
* })
* class MyComponent implements OnInit, OnDestroy {
* ngOnInit() {
* console.log('ngOnInit');
* }
*
* ngOnDestroy() {
* console.log('ngOnDestroy');
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="hasChild = !hasChild">
* {{hasChild ? 'Destroy' : 'Create'}} MyComponent
* </button>
* <my-cmp *ngIf="hasChild"></my-cmp>`,
* directives: [MyComponent, NgIf]
* })
* export class App {
* hasChild = true;
* }
* ```
* @stable

@@ -129,66 +70,20 @@ */

/**
* Implement this interface to supplement the default change detection algorithm in your directive.
* @whatItDoes Lifecycle hook that is called when Angular dirty checks a directive.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
*
* @description
* `ngDoCheck` gets called to check the changes in the directives in addition to the default
* algorithm.
* algorithm. The default change detection algorithm looks for differences by comparing
* bound-property values by reference across change detection runs.
*
* The default change detection algorithm looks for differences by comparing bound-property values
* by reference across change detection runs.
*
* Note that a directive typically should not use both `DoCheck` and {@link OnChanges} to respond to
* changes on the same input. `ngOnChanges` will continue to be called when the default change
* detector
* detects changes, so it is usually unnecessary to respond to changes on the same input in both
* hooks.
* Reaction to the changes have to be handled from within the `ngDoCheck` callback.
* changes on the same input, as `ngOnChanges` will continue to be called when the default change
* detector detects changes.
*
* You can use {@link KeyValueDiffers} and {@link IterableDiffers} to help add your custom check
* mechanisms.
* See {@link KeyValueDiffers} and {@link IterableDiffers} for implementing custom dirty checking
* for collections.
*
* ### Example ([live demo](http://plnkr.co/edit/QpnIlF0CR2i5bcYbHEUJ?p=preview))
* See {@linkDocs guide/lifecycle-hooks#docheck "Lifecycle Hooks Guide"}.
*
* In the following example `ngDoCheck` uses an {@link IterableDiffers} to detect the updates to the
* array `list`:
*
* ```typescript
* @Component({
* selector: 'custom-check',
* template: `
* <p>Changes:</p>
* <ul>
* <li *ngFor="let line of logs">{{line}}</li>
* </ul>`,
* directives: [NgFor]
* })
* class CustomCheckComponent implements DoCheck {
* @Input() list: any[];
* differ: any;
* logs = [];
*
* constructor(differs: IterableDiffers) {
* this.differ = differs.find([]).create(null);
* }
*
* ngDoCheck() {
* var changes = this.differ.diff(this.list);
*
* if (changes) {
* changes.forEachAddedItem(r => this.logs.push('added ' + r.item));
* changes.forEachRemovedItem(r => this.logs.push('removed ' + r.item))
* }
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="list.push(list.length)">Push</button>
* <button (click)="list.pop()">Pop</button>
* <custom-check [list]="list"></custom-check>`,
* directives: [CustomCheckComponent]
* })
* export class App {
* list = [];
* }
* ```
* @stable

@@ -202,87 +97,12 @@ */

/**
* Implement this interface to get notified when your directive is destroyed.
* @whatItDoes Lifecycle hook that is called when a directive or pipe is destroyed.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
*
* @description
* `ngOnDestroy` callback is typically used for any custom cleanup that needs to occur when the
* instance is destroyed
* instance is destroyed.
*
* ### Example ([live example](http://plnkr.co/edit/1MBypRryXd64v4pV03Yn?p=preview))
* See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* ```typesript
* @Component({
* selector: 'my-cmp',
* template: `<p>my-component</p>`
* })
* class MyComponent implements OnInit, OnDestroy {
* ngOnInit() {
* console.log('ngOnInit');
* }
*
* ngOnDestroy() {
* console.log('ngOnDestroy');
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <button (click)="hasChild = !hasChild">
* {{hasChild ? 'Destroy' : 'Create'}} MyComponent
* </button>
* <my-cmp *ngIf="hasChild"></my-cmp>`,
* directives: [MyComponent, NgIf]
* })
* export class App {
* hasChild = true;
* }
* ```
*
*
* To create a stateful Pipe, you should implement this interface and set the `pure`
* parameter to `false` in the {@link Pipe}.
*
* A stateful pipe may produce different output, given the same input. It is
* likely that a stateful pipe may contain state that should be cleaned up when
* a binding is destroyed. For example, a subscription to a stream of data may need to
* be disposed, or an interval may need to be cleared.
*
* ### Example ([live demo](http://plnkr.co/edit/i8pm5brO4sPaLxBx56MR?p=preview))
*
* In this example, a pipe is created to countdown its input value, updating it every
* 50ms. Because it maintains an internal interval, it automatically clears
* the interval when the binding is destroyed or the countdown completes.
*
* ```
* import {OnDestroy, Pipe, PipeTransform} from '@angular/core'
* @Pipe({name: 'countdown', pure: false})
* class CountDown implements PipeTransform, OnDestroy {
* remainingTime:Number;
* interval:SetInterval;
* ngOnDestroy() {
* if (this.interval) {
* clearInterval(this.interval);
* }
* }
* transform(value: any, args: any[] = []) {
* if (!parseInt(value, 10)) return null;
* if (typeof this.remainingTime !== 'number') {
* this.remainingTime = parseInt(value, 10);
* }
* if (!this.interval) {
* this.interval = setInterval(() => {
* this.remainingTime-=50;
* if (this.remainingTime <= 0) {
* this.remainingTime = 0;
* clearInterval(this.interval);
* delete this.interval;
* }
* }, 50);
* }
* return this.remainingTime;
* }
* }
* ```
*
* Invoking `{{ 10000 | countdown }}` would cause the value to be decremented by 50,
* every 50ms, until it reaches 0.
*
* @stable

@@ -296,49 +116,11 @@ */

/**
* Implement this interface to get notified when your directive's content has been fully
*
* @whatItDoes Lifecycle hook that is called after a directive's content has been fully
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
*
* ### Example ([live demo](http://plnkr.co/edit/plamXUpsLQbIXpViZhUO?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({
* selector: 'child-cmp',
* template: `{{where}} child`
* })
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `<ng-content></ng-content>`
* })
* class ParentComponent implements AfterContentInit {
* @ContentChild(ChildComponent) contentChild: ChildComponent;
*
* constructor() {
* // contentChild is not initialized yet
* console.log(this.getMessage(this.contentChild));
* }
*
* ngAfterContentInit() {
* // contentChild is updated after the content has been checked
* console.log('AfterContentInit: ' + this.getMessage(this.contentChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <parent-cmp>
* <child-cmp where="content"></child-cmp>
* </parent-cmp>`,
* directives: [ParentComponent, ChildComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -352,44 +134,9 @@ */

/**
* Implement this interface to get notified after every check of your directive's content.
* @whatItDoes Lifecycle hook that is called after every check of a directive's content.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
*
* ### Example ([live demo](http://plnkr.co/edit/tGdrytNEKQnecIPkD7NU?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({selector: 'parent-cmp', template: `<ng-content></ng-content>`})
* class ParentComponent implements AfterContentChecked {
* @ContentChild(ChildComponent) contentChild: ChildComponent;
*
* constructor() {
* // contentChild is not initialized yet
* console.log(this.getMessage(this.contentChild));
* }
*
* ngAfterContentChecked() {
* // contentChild is updated after the content has been checked
* console.log('AfterContentChecked: ' + this.getMessage(this.contentChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `
* <parent-cmp>
* <button (click)="hasContent = !hasContent">Toggle content child</button>
* <child-cmp *ngIf="hasContent" where="content"></child-cmp>
* </parent-cmp>`,
* directives: [NgIf, ParentComponent, ChildComponent]
* })
* export class App {
* hasContent = true;
* }
* ```
* @stable

@@ -403,43 +150,10 @@ */

/**
* Implement this interface to get notified when your component's view has been fully initialized.
* @whatItDoes Lifecycle hook that is called after a component's view has been fully
* initialized.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
*
* ### Example ([live demo](http://plnkr.co/edit/LhTKVMEM0fkJgyp4CI1W?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `<child-cmp where="view"></child-cmp>`,
* directives: [ChildComponent]
* })
* class ParentComponent implements AfterViewInit {
* @ViewChild(ChildComponent) viewChild: ChildComponent;
*
* constructor() {
* // viewChild is not initialized yet
* console.log(this.getMessage(this.viewChild));
* }
*
* ngAfterViewInit() {
* // viewChild is updated after the view has been initialized
* console.log('ngAfterViewInit: ' + this.getMessage(this.viewChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `<parent-cmp></parent-cmp>`,
* directives: [ParentComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -453,46 +167,9 @@ */

/**
* Implement this interface to get notified after every check of your component's view.
* @whatItDoes Lifecycle hook that is called after every check of a component's view.
* @howToUse
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
*
* ### Example ([live demo](http://plnkr.co/edit/0qDGHcPQkc25CXhTNzKU?p=preview))
* @description
* See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* ```typescript
* @Component({selector: 'child-cmp', template: `{{where}} child`})
* class ChildComponent {
* @Input() where: string;
* }
*
* @Component({
* selector: 'parent-cmp',
* template: `
* <button (click)="showView = !showView">Toggle view child</button>
* <child-cmp *ngIf="showView" where="view"></child-cmp>`,
* directives: [NgIf, ChildComponent]
* })
* class ParentComponent implements AfterViewChecked {
* @ViewChild(ChildComponent) viewChild: ChildComponent;
* showView = true;
*
* constructor() {
* // viewChild is not initialized yet
* console.log(this.getMessage(this.viewChild));
* }
*
* ngAfterViewChecked() {
* // viewChild is updated after the view has been checked
* console.log('AfterViewChecked: ' + this.getMessage(this.viewChild));
* }
*
* private getMessage(cmp: ChildComponent): string {
* return cmp ? cmp.where + ' child' : 'no child';
* }
* }
*
* @Component({
* selector: 'app',
* template: `<parent-cmp></parent-cmp>`,
* directives: [ParentComponent]
* })
* export class App {
* }
* ```
* @stable

@@ -499,0 +176,0 @@ */

@@ -9,4 +9,6 @@ /**

/**
* Runtime representation a type that a Component or other object is instances of.
* @whatItDoes Represents a type that a Component or other object is instances of.
*
* @description
*
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by

@@ -13,0 +15,0 @@ * the `MyCustomComponent` constructor function.

@@ -9,4 +9,6 @@ /**

/**
* Runtime representation a type that a Component or other object is instances of.
* @whatItDoes Represents a type that a Component or other object is instances of.
*
* @description
*
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by

@@ -13,0 +15,0 @@ * the `MyCustomComponent` constructor function.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc