parent
e950dd6a2a
commit
2835265916
|
@ -2,12 +2,17 @@
|
||||||
Bootstrapping
|
Bootstrapping
|
||||||
@cheatsheetIndex 0
|
@cheatsheetIndex 0
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {bootstrap} from 'angular2/platform/browser';`{@endtarget}
|
{@target ts}`import {bootstrap} from 'angular2/angular2';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.platform.browser` namespace.{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`bootstrap(MyAppComponent, [MyService, provide(...)]);`|`provide`
|
`bootstrap(MyAppComponent, [MyService, provide(...)]);`|`provide`
|
||||||
|
syntax(js):
|
||||||
|
`document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
ng.platform.browser.bootstrap(MyAppComponent,
|
||||||
|
[MyService, ng.core.provide(...)]);
|
||||||
|
});`|`provide`
|
||||||
description:
|
description:
|
||||||
Bootstraps an application with MyAppComponent as the root component, and
|
Bootstraps an application with MyAppComponent as the root component and configures the DI providers. {@target js}Must be wrapped in the event listener to fire when the page loads.{@endtarget}
|
||||||
configures the app's dependency injection providers.
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Built-in directives
|
Built-in directives
|
||||||
@cheatsheetIndex 2
|
@cheatsheetIndex 2
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {NgIf, ...} from 'angular2/common';`{@endtarget}
|
{@target ts}`import {NgIf, ...} from 'angular2/common';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.common` namespace{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/common.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/common.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
Class decorators
|
Class decorators
|
||||||
@cheatsheetIndex 4
|
@cheatsheetIndex 4
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {Directive, ...} from 'angular2/core';`{@endtarget}
|
{@target ts}`import {Directive, ...} from 'angular2/core';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`@Component({...})
|
`@Component({...})
|
||||||
class MyComponent() {}`|`@Component({...})`
|
class MyComponent() {}`|`@Component({...})`
|
||||||
|
syntax(js):
|
||||||
|
`var MyComponent = ng.core.Component({...}).Class({...})`|`ng.core.Component({...})`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`@Component(...)
|
`@Component(...)
|
||||||
class MyComponent() {}`|`@Component(...)`
|
class MyComponent() {}`|`@Component(...)`
|
||||||
|
@ -16,9 +19,11 @@ description:
|
||||||
Declares that a class is a component and provides metadata about the component.
|
Declares that a class is a component and provides metadata about the component.
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`@Pipe({...})
|
`@Pipe({...})
|
||||||
class MyPipe() {}`|`@Pipe({...})`
|
class MyPipe() {}`|`@Pipe({...})`
|
||||||
|
syntax(js):
|
||||||
|
`var MyPipe = ng.core.Pipe({...}).Class({...})`|`ng.core.Pipe({...})`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`@Pipe(...)
|
`@Pipe(...)
|
||||||
class MyPipe() {}`|`@Pipe(...)`
|
class MyPipe() {}`|`@Pipe(...)`
|
||||||
|
@ -26,12 +31,19 @@ description:
|
||||||
Declares that a class is a pipe and provides metadata about the pipe.
|
Declares that a class is a pipe and provides metadata about the pipe.
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`@Injectable()
|
`@Injectable()
|
||||||
class MyService() {}`|`@Injectable()`
|
class MyService() {}`|`@Injectable()`
|
||||||
|
syntax(js):
|
||||||
|
`var MyService = ng.core.Class({constructor: [OtherService, function(otherService) { }]});
|
||||||
|
var OtherService = ng.core.Class({constructor: function() { }});`
|
||||||
|
var MyService = ng.core.Injectable({...})`|`ng.core.Injectable({...})`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`@Injectable()
|
`@Injectable()
|
||||||
class MyService() {}`|`@Injectable()`
|
class MyService() {}`|`@Injectable()`
|
||||||
description:
|
description:
|
||||||
Declares that a class has dependencies that should be injected into the constructor when the dependency
|
{@target ts dart}Declares that a class has dependencies that should be injected into the constructor when the dependency injector is creating an instance of this class.
|
||||||
injector is creating an instance of this class.
|
{@endtarget}
|
||||||
|
{@target js}
|
||||||
|
Declares a service to inject into a class by providing an array with the services with the final item being the function which will receive the injected services.
|
||||||
|
{@endtarget}
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
Component configuration
|
Component configuration
|
||||||
@cheatsheetIndex 6
|
@cheatsheetIndex 6
|
||||||
@description
|
@description
|
||||||
`@Component` extends `@Directive`,
|
{@target js}`ng.core.Component` extends `ng.core.Directive`,
|
||||||
so the `@Directive` configuration applies to components as well
|
so the `ng.core.Directive` configuration applies to components as well{@endtarget}
|
||||||
|
{@target ts dart}`@Component` extends `@Directive`,
|
||||||
|
so the `@Directive` configuration applies to components as well{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
|
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
|
||||||
|
syntax(js):
|
||||||
|
`viewProviders: [MyService, ng.core.provide(...)]`|`viewProviders:`
|
||||||
description:
|
description:
|
||||||
Array of dependency injection providers scoped to this component's view.
|
Array of dependency injection providers scoped to this component's view.
|
||||||
|
|
||||||
|
|
|
@ -2,26 +2,32 @@
|
||||||
Dependency injection configuration
|
Dependency injection configuration
|
||||||
@cheatsheetIndex 9
|
@cheatsheetIndex 9
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {provide} from 'angular2/core';`{@endtarget}
|
{@target ts}`import {provide} from 'angular2/core';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
`provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
||||||
description:
|
description:
|
||||||
Sets or overrides the provider for MyService to the MyMockService class.
|
Sets or overrides the provider for MyService to the MyMockService class.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
`provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
||||||
description:
|
description:
|
||||||
Sets or overrides the provider for MyService to the myFactory factory function.
|
Sets or overrides the provider for MyService to the myFactory factory function.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
|
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
||||||
|
syntax(js):
|
||||||
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
||||||
description:
|
description:
|
||||||
Sets or overrides the provider for MyValue to the value 41.
|
Sets or overrides the provider for MyValue to the value 41.
|
||||||
|
|
||||||
|
|
|
@ -2,62 +2,79 @@
|
||||||
Class field decorators for directives and components
|
Class field decorators for directives and components
|
||||||
@cheatsheetIndex 7
|
@cheatsheetIndex 7
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {Input, ...} from 'angular2/core';`{@endtarget}
|
{@target ts}`import {Input, ...} from 'angular2/core';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@Input() myProperty;`|`@Input()`
|
`@Input() myProperty;`|`@Input()`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.Input(myProperty, myComponent);`|`ng.core.Input(`|`);`
|
||||||
description:
|
description:
|
||||||
Declares an input property that we can update via property binding (e.g.
|
Declares an input property that we can update via property binding (e.g.
|
||||||
`<my-cmp [my-property]="someExpression">`).
|
`<my-cmp [my-property]="someExpression">`).
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@Output() myEvent = new EventEmitter();`|`@Output()`
|
`@Output() myEvent = new EventEmitter();`|`@Output()`
|
||||||
|
syntax(js):
|
||||||
|
`myEvent = new ng.core.EventEmitter(); ng.core.Output(myEvent, myComponent);`|`ng.core.Output(`|`);`
|
||||||
description:
|
description:
|
||||||
Declares an output property that fires events to which we can subscribe with an event binding (e.g. `<my-cmp (my-event)="doSomething()">`).
|
Declares an output property that fires events to which we can subscribe with an event binding (e.g. `<my-cmp (my-event)="doSomething()">`).
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')`
|
`@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.HostBinding('[class.valid]', 'isValid', myComponent);`|`ng.core.HostBinding('[class.valid]', 'isValid'`|`);`
|
||||||
description:
|
description:
|
||||||
Binds a host element property (e.g. CSS class valid) to directive/component property (e.g. isValid).
|
Binds a host element property (e.g. CSS class valid) to directive/component property (e.g. isValid).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])`
|
`@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.HostListener('click', ['$event'], onClick(e) {...}, myComponent);`|`ng.core.HostListener('click', ['$event'], onClick(e)`|`);`
|
||||||
description:
|
description:
|
||||||
Subscribes to a host element event (e.g. click) with a directive/component method (e.g. onClick), optionally passing an argument ($event).
|
Subscribes to a host element event (e.g. click) with a directive/component method (e.g. onClick), optionally passing an argument ($event).
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)`
|
`@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.ContentChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ContentChild(myPredicate,`|`);`
|
||||||
description:
|
description:
|
||||||
Binds the first result of the component content query (myPredicate) to the myChildComponent property of the class.
|
Binds the first result of the component content query (myPredicate) to the myChildComponent property of the class.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)`
|
`@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.ContentChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ContentChildren(myPredicate,`|`);`
|
||||||
description:
|
description:
|
||||||
Binds the results of the component content query (myPredicate) to the myChildComponents property of the class.
|
Binds the results of the component content query (myPredicate) to the myChildComponents property of the class.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)`
|
`@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.ViewChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ViewChild(myPredicate,`|`);`
|
||||||
description:
|
description:
|
||||||
Binds the first result of the component view query (myPredicate) to the myChildComponent property of the class. Not available for directives.
|
Binds the first result of the component view query (myPredicate) to the myChildComponent property of the class. Not available for directives.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)`
|
`@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)`
|
||||||
|
syntax(js):
|
||||||
|
`ng.core.ViewChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ViewChildren(myPredicate,`|`);`
|
||||||
description:
|
description:
|
||||||
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.
|
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Directive configuration
|
Directive configuration
|
||||||
@cheatsheetIndex 5
|
@cheatsheetIndex 5
|
||||||
@description
|
@description
|
||||||
{@target js ts}`@Directive({ property1: value1, ... })`{@endtarget}
|
{@target ts}`@Directive({ property1: value1, ... })`{@endtarget}
|
||||||
|
{@target js}`ng.core.Directive({ property1: value1, ... }).Class({...})`{@endtarget}
|
||||||
{@target dart}`@Directive(property1: value1, ...)`{@endtarget}
|
{@target dart}`@Directive(property1: value1, ...)`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
|
@ -15,7 +16,9 @@ Specifies a CSS selector that identifies this directive within a template. Suppo
|
||||||
Does not support parent-child relationship selectors.
|
Does not support parent-child relationship selectors.
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`providers: [MyService, provide(...)]`|`providers:`
|
`providers: [MyService, provide(...)]`|`providers:`
|
||||||
|
syntax(js):
|
||||||
|
`providers: [MyService, ng.core.provide(...)]`|`providers:`
|
||||||
description:
|
description:
|
||||||
Array of dependency injection providers for this directive and its children.
|
Array of dependency injection providers for this directive and its children.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
Forms
|
Forms
|
||||||
@cheatsheetIndex 3
|
@cheatsheetIndex 3
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {FORM_DIRECTIVES} from 'angular2/common';`{@endtarget}
|
{@target ts}`import {FORM_DIRECTIVES} from 'angular2/common';`{@endtarget}
|
||||||
|
{@target js}Available from `ng.common.FORM_DIRECTIVES`{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/common.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/common.dart';`{@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
Directive and component change detection and lifecycle hooks
|
Directive and component change detection and lifecycle hooks
|
||||||
@cheatsheetIndex 8
|
@cheatsheetIndex 8
|
||||||
@description
|
@description
|
||||||
(implemented as class methods)
|
{@target ts dart}(implemented as class methods){@endtarget}
|
||||||
|
{@target js}(implemented as component properties){@endtarget}
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)`
|
`constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)`
|
||||||
|
syntax(js):
|
||||||
|
`constructor: function(MyService, ...) { ... }`|`constructor: function(MyService, ...)`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`MyAppComponent(MyService myService, ...) { ... }`|`MyAppComponent(MyService myService, ...)`
|
`MyAppComponent(MyService myService, ...) { ... }`|`MyAppComponent(MyService myService, ...)`
|
||||||
description:
|
description:
|
||||||
|
@ -14,56 +17,72 @@ The class constructor is called before any other lifecycle hook. Use it to injec
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)`
|
`ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)`
|
||||||
|
syntax(js):
|
||||||
|
`ngOnChanges: function(changeRecord) { ... }`|`ngOnChanges: function(changeRecord)`
|
||||||
description:
|
description:
|
||||||
Called after every change to input properties and before processing content or child views.
|
Called after every change to input properties and before processing content or child views.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngOnInit() { ... }`|`ngOnInit()`
|
`ngOnInit() { ... }`|`ngOnInit()`
|
||||||
|
syntax(js):
|
||||||
|
`ngOnInit: function() { ... }`|`ngOnInit: function()`
|
||||||
description:
|
description:
|
||||||
Called after the constructor, initializing input properties, and the first call to ngOnChanges.
|
Called after the constructor, initializing input properties, and the first call to ngOnChanges.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngDoCheck() { ... }`|`ngDoCheck()`
|
`ngDoCheck() { ... }`|`ngDoCheck()`
|
||||||
|
syntax(js):
|
||||||
|
`ngDoCheck: function() { ... }`|`ngDoCheck: function()`
|
||||||
description:
|
description:
|
||||||
Called every time that the input properties of a component or a directive are checked. Use it to extend change detection by performing a custom check.
|
Called every time that the input properties of a component or a directive are checked. Use it to extend change detection by performing a custom check.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngAfterContentInit() { ... }`|`ngAfterContentInit()`
|
`ngAfterContentInit() { ... }`|`ngAfterContentInit()`
|
||||||
|
syntax(js):
|
||||||
|
`ngAfterContentInit: function() { ... }`|`ngAfterContentInit: function()`
|
||||||
description:
|
description:
|
||||||
Called after ngOnInit when the component's or directive's content has been initialized.
|
Called after ngOnInit when the component's or directive's content has been initialized.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngAfterContentChecked() { ... }`|`ngAfterContentChecked()`
|
`ngAfterContentChecked() { ... }`|`ngAfterContentChecked()`
|
||||||
|
syntax(js):
|
||||||
|
`ngAfterContentChecked: function() { ... }`|`ngAfterContentChecked: function()`
|
||||||
description:
|
description:
|
||||||
Called after every check of the component's or directive's content.
|
Called after every check of the component's or directive's content.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngAfterViewInit() { ... }`|`ngAfterViewInit()`
|
`ngAfterViewInit() { ... }`|`ngAfterViewInit()`
|
||||||
|
syntax(js):
|
||||||
|
`ngAfterViewInit: function() { ... }`|`ngAfterViewInit: function()`
|
||||||
description:
|
description:
|
||||||
Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
|
Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngAfterViewChecked() { ... }`|`ngAfterViewChecked()`
|
`ngAfterViewChecked() { ... }`|`ngAfterViewChecked()`
|
||||||
|
syntax(js):
|
||||||
|
`ngAfterViewChecked: function() { ... }`|`ngAfterViewChecked: function()`
|
||||||
description:
|
description:
|
||||||
Called after every check of the component's view. Applies to components only.
|
Called after every check of the component's view. Applies to components only.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`ngOnDestroy() { ... }`|`ngOnDestroy()`
|
`ngOnDestroy() { ... }`|`ngOnDestroy()`
|
||||||
|
syntax(js):
|
||||||
|
`ngOnDestroy: function() { ... }`|`ngOnDestroy: function()`
|
||||||
description:
|
description:
|
||||||
Called once, before the instance is destroyed.
|
Called once, before the instance is destroyed.
|
||||||
|
|
|
@ -2,18 +2,27 @@
|
||||||
Routing and navigation
|
Routing and navigation
|
||||||
@cheatsheetIndex 10
|
@cheatsheetIndex 10
|
||||||
@description
|
@description
|
||||||
{@target js ts}`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`{@endtarget}
|
{@target ts}`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`{@endtarget}
|
||||||
|
{@target js}Available from the `ng.router` namespace{@endtarget}
|
||||||
{@target dart}`import 'package:angular2/router.dart';`{@endtarget}
|
{@target dart}`import 'package:angular2/router.dart';`{@endtarget}
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`@RouteConfig([
|
`@RouteConfig([
|
||||||
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
|
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
|
||||||
{ path: '/staticPath', component: ..., as: ...},
|
{ path: '/staticPath', component: ..., as: ...},
|
||||||
{ path: '/*wildCardParam', component: ..., as: ...}
|
{ path: '/*wildCardParam', component: ..., as: ...}
|
||||||
])
|
])
|
||||||
class MyComponent() {}`|`@RouteConfig`
|
class MyComponent() {}`|`@RouteConfig`
|
||||||
|
syntax(js):
|
||||||
|
`var MyComponent = ng.router.RouteConfig([
|
||||||
|
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
|
||||||
|
{ path: '/staticPath', component: ..., as: ...},
|
||||||
|
{ path: '/*wildCardParam', component: ..., as: ...}
|
||||||
|
]).Class({
|
||||||
|
constructor: function() {}
|
||||||
|
});`|`ng.router.RouteConfig`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`@RouteConfig(const [
|
`@RouteConfig(const [
|
||||||
const Route(path: '/:myParam', component: MyComponent, name: 'MyCmp' ),
|
const Route(path: '/:myParam', component: MyComponent, name: 'MyCmp' ),
|
||||||
|
@ -37,8 +46,10 @@ Creates a link to a different view based on a route instruction consisting of a
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax(js ts):
|
syntax(ts):
|
||||||
`@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate`
|
`@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate`
|
||||||
|
syntax(js):
|
||||||
|
`var MyComponent = ng.router.CanActivate(function() { ... }).Component({...}).Class({constructor: ...});`|`ng.router.CanActivate(function() { ... })`
|
||||||
syntax(dart):
|
syntax(dart):
|
||||||
`@CanActivate(() => ...)class MyComponent() {}`|`@CanActivate`
|
`@CanActivate(() => ...)class MyComponent() {}`|`@CanActivate`
|
||||||
description:
|
description:
|
||||||
|
@ -46,35 +57,45 @@ A component decorator defining a function that the router should call first to d
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
|
`routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
|
||||||
|
syntax(js):
|
||||||
|
`routerOnActivate: function(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
|
||||||
description:
|
description:
|
||||||
After navigating to a component, the router calls the component's routerOnActivate method (if defined).
|
After navigating to a component, the router calls the component's routerOnActivate method (if defined).
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
|
`routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
|
||||||
|
syntax(js):
|
||||||
|
`routerCanReuse: function(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
|
||||||
description:
|
description:
|
||||||
The router calls a component's routerCanReuse method (if defined) to determine whether to reuse the instance or destroy it and create a new instance. Should return a boolean or a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget}.
|
The router calls a component's routerCanReuse method (if defined) to determine whether to reuse the instance or destroy it and create a new instance. Should return a boolean or a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget}.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
|
`routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
|
||||||
|
syntax(js):
|
||||||
|
`routerOnReuse: function(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
|
||||||
description:
|
description:
|
||||||
The router calls the component's routerOnReuse method (if defined) when it re-uses a component instance.
|
The router calls the component's routerOnReuse method (if defined) when it re-uses a component instance.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
|
`routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
|
||||||
|
syntax(js):
|
||||||
|
`routerCanDeactivate: function(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
|
||||||
description:
|
description:
|
||||||
The router calls the routerCanDeactivate methods (if defined) of every component that would be removed after a navigation. The navigation proceeds if and only if all such methods return true or a {@target js ts}promise that is resolved{@endtarget}{@target dart}future that completes successfully{@endtarget}.
|
The router calls the routerCanDeactivate methods (if defined) of every component that would be removed after a navigation. The navigation proceeds if and only if all such methods return true or a {@target js ts}promise that is resolved{@endtarget}{@target dart}future that completes successfully{@endtarget}.
|
||||||
|
|
||||||
|
|
||||||
@cheatsheetItem
|
@cheatsheetItem
|
||||||
syntax:
|
syntax(ts dart):
|
||||||
`routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
|
`routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
|
||||||
|
syntax(js):
|
||||||
|
`routerOnDeactivate: function(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
|
||||||
description:
|
description:
|
||||||
Called before the directive is removed as the result of a route change. May return a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget} that pauses removing the directive until the {@target js ts}promise resolves{@endtarget}{@target dart}future completes{@endtarget}.
|
Called before the directive is removed as the result of a route change. May return a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget} that pauses removing the directive until the {@target js ts}promise resolves{@endtarget}{@target dart}future completes{@endtarget}.
|
||||||
|
|
Loading…
Reference in New Issue