docs(cheatsheet): update to new syntax
See https://github.com/angular/angular.io/pull/459 Closes #5733
This commit is contained in:
		
							parent
							
								
									ca73852746
								
							
						
					
					
						commit
						2f0744b089
					
				| @ -2,8 +2,11 @@ | |||||||
| Bootstrapping | Bootstrapping | ||||||
| @cheatsheetIndex 0 | @cheatsheetIndex 0 | ||||||
| @description | @description | ||||||
| `import {bootstrap} from 'angular2/angular2';` | {@target js ts}`import {bootstrap} from 'angular2/angular2';`{@endtarget} | ||||||
|  | {@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget} | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
| `bootstrap(MyAppComponent, [MyService, provide(...)]);` | syntax: | ||||||
|  | `bootstrap(MyAppComponent, [MyService, provide(...)]);`|`provide` | ||||||
|  | description: | ||||||
| Bootstraps an application with MyAppComponent as the root component and configures the DI providers. | Bootstraps an application with MyAppComponent as the root component and configures the DI providers. | ||||||
|  | |||||||
| @ -5,21 +5,29 @@ Built-in directives | |||||||
| `import {NgIf, ...} from 'angular2/angular2';` | `import {NgIf, ...} from 'angular2/angular2';` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<section *ng-if="showSection">`|`*ng-if` | `<section *ng-if="showSection">`|`*ng-if` | ||||||
|  | description: | ||||||
| Removes or recreates a portion of the DOM tree based on the showSection expression. | Removes or recreates a portion of the DOM tree based on the showSection expression. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<li *ng-for="#item of list">`|`*ng-for` | `<li *ng-for="#item of list">`|`*ng-for` | ||||||
|  | description: | ||||||
| Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list. | Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div [ng-switch]="conditionExpression"> | `<div [ng-switch]="conditionExpression"> | ||||||
|   <template [ng-switch-when]="case1Exp">...</template> |   <template [ng-switch-when]="case1Exp">...</template> | ||||||
|   <template ng-switch-when="case2LiteralString">...</template> |   <template ng-switch-when="case2LiteralString">...</template> | ||||||
|   <template ng-switch-default>...</template> |   <template ng-switch-default>...</template> | ||||||
| </div>`|`[ng-switch]`|`[ng-switch-when]`|`ng-switch-when`|`ng-switch-default` | </div>`|`[ng-switch]`|`[ng-switch-when]`|`ng-switch-when`|`ng-switch-default` | ||||||
|  | description: | ||||||
| Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression. | Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div [ng-class]="{active: isActive, disabled: isDisabled}">`|`[ng-class]` | `<div [ng-class]="{active: isActive, disabled: isDisabled}">`|`[ng-class]` | ||||||
|  | description: | ||||||
| Binds the presence of css classes on the element to the truthiness of the associated map values. The right-hand side expression should return {class-name: true/false} map. | Binds the presence of css classes on the element to the truthiness of the associated map values. The right-hand side expression should return {class-name: true/false} map. | ||||||
| @ -5,17 +5,23 @@ Class decorators | |||||||
| `import {Directive, ...} from 'angular2/angular2';` | `import {Directive, ...} from 'angular2/angular2';` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `@Component({...}) | `@Component({...}) | ||||||
| class MyComponent() {}`|`@Component({...})` | class MyComponent() {}`|`@Component({...})` | ||||||
|  | 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: | ||||||
| `@Pipe({...}) | `@Pipe({...}) | ||||||
| class MyPipe() {}`|`@Pipe({...})` | class MyPipe() {}`|`@Pipe({...})` | ||||||
|  | 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: | ||||||
| `@Injectable() | `@Injectable() | ||||||
| class MyService() {}`|`@Injectable()` | class MyService() {}`|`@Injectable()` | ||||||
|  | description: | ||||||
| Declares that a class has dependencies that should be injected into the constructor when the dependency | 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. | ||||||
| @ -6,27 +6,37 @@ Component configuration | |||||||
| so the `@Directive` configuration applies to components as well | so the `@Directive` configuration applies to components as well | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `viewProviders: [MyService, provide(...)]`|`viewProviders:` | `viewProviders: [MyService, provide(...)]`|`viewProviders:` | ||||||
|  | description: | ||||||
| Array of dependency injection providers scoped to this component's view. | Array of dependency injection providers scoped to this component's view. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `template: 'Hello {{name}}' | `template: 'Hello {{name}}' | ||||||
| templateUrl: 'my-component.html'`|`template:`|`templateUrl:` | templateUrl: 'my-component.html'`|`template:`|`templateUrl:` | ||||||
|  | description: | ||||||
| Inline template / external template url of the component's view. | Inline template / external template url of the component's view. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `styles: ['.primary {color: red}'] | `styles: ['.primary {color: red}'] | ||||||
| styleUrls: ['my-component.css']`|`styles:`|`styleUrls:` | styleUrls: ['my-component.css']`|`styles:`|`styleUrls:` | ||||||
|  | description: | ||||||
| List of inline css styles / external stylesheet urls for styling component’s view. | List of inline css styles / external stylesheet urls for styling component’s view. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `directives: [MyDirective, MyComponent]`|`directives:` | `directives: [MyDirective, MyComponent]`|`directives:` | ||||||
|  | description: | ||||||
| List of directives used in the the component’s template. | List of directives used in the the component’s template. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `pipes: [MyPipe, OtherPipe]`|`pipes:` | `pipes: [MyPipe, OtherPipe]`|`pipes:` | ||||||
|  | description: | ||||||
| List of pipes used in the component's template. | List of pipes used in the component's template. | ||||||
| @ -5,16 +5,22 @@ Dependency injection configuration | |||||||
| `import {provide} from 'angular2/angular2';` | `import {provide} from 'angular2/angular2';` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
| `provide(MyService, {useClass: MyMockService})``provide`|`useClass` | syntax: | ||||||
|  | `provide(MyService, {useClass: MyMockService})`|`provide`|`useClass` | ||||||
|  | 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 | ||||||
| `provide(MyService, {useFactory: myFactory})``provide`|`useFactory` | syntax: | ||||||
|  | `provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory` | ||||||
|  | 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 | ||||||
| `provide(MyValue, {useValue: 41})``provide`|`useValue` | syntax: | ||||||
|  | `provide(MyValue, {useValue: 41})`|`provide`|`useValue` | ||||||
|  | description: | ||||||
| Sets or overrides the provider for MyValue to the value 41. | Sets or overrides the provider for MyValue to the value 41. | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,42 +5,58 @@ Class field decorators for directives and components | |||||||
| `import {Input, ...} from 'angular2/angular2';` | `import {Input, ...} from 'angular2/angular2';` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `@Input() myProperty;`|`@Input()` | `@Input() myProperty;`|`@Input()` | ||||||
|  | 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: | ||||||
| `@Output() myEvent = new EventEmitter();`|`@Output()` | `@Output() myEvent = new EventEmitter();`|`@Output()` | ||||||
|  | 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: | ||||||
| `@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')` | `@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')` | ||||||
|  | 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: | ||||||
| `@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])` | `@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])` | ||||||
|  | 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: | ||||||
| `@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)` | `@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)` | ||||||
|  | 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: | ||||||
| `@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)` | `@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)` | ||||||
|  | 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: | ||||||
| `@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)` | `@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)` | ||||||
|  | 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: | ||||||
| `@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)` | `@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)` | ||||||
|  | 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. | ||||||
| @ -5,12 +5,16 @@ Directive configuration | |||||||
| `@Directive({ property1: value1, ... }) )` | `@Directive({ property1: value1, ... }) )` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `selector: '.cool-button:not(a)'`|`selector:` | `selector: '.cool-button:not(a)'`|`selector:` | ||||||
|  | description: | ||||||
| Specifies a css selector that identifies this directive within a template. Supported selectors include: `element`, | Specifies a css selector that identifies this directive within a template. Supported selectors include: `element`, | ||||||
| `[attribute]`, `.class`, and `:not()`. | `[attribute]`, `.class`, and `:not()`. | ||||||
| 
 | 
 | ||||||
| Does not support parent-child relationship selectors. | Does not support parent-child relationship selectors. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `providers: [MyService, provide(...)]`|`providers:` | `providers: [MyService, provide(...)]`|`providers:` | ||||||
|  | description: | ||||||
| Array of dependency injection providers for this directive and its children. | Array of dependency injection providers for this directive and its children. | ||||||
| @ -5,5 +5,7 @@ Forms | |||||||
| `import {FORM_DIRECTIVES} from 'angular2/angular2';` | `import {FORM_DIRECTIVES} from 'angular2/angular2';` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<input [(ng-model)]="userName">`|`[(ng-model)]` | `<input [(ng-model)]="userName">`|`[(ng-model)]` | ||||||
|  | description: | ||||||
| Provides two-way data-binding, parsing and validation for form controls. | Provides two-way data-binding, parsing and validation for form controls. | ||||||
| @ -5,45 +5,63 @@ Directive and component change detection and lifecycle hooks | |||||||
| (implemented as class methods) | (implemented as class methods) | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)` | `constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)` | ||||||
|  | description: | ||||||
| The class constructor is called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here. | The class constructor is called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)` | `ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)` | ||||||
|  | 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: | ||||||
| `ngOnInit() { ... }`|`ngOnInit()` | `ngOnInit() { ... }`|`ngOnInit()` | ||||||
|  | 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: | ||||||
| `ngDoCheck() { ... }`|`ngDoCheck()` | `ngDoCheck() { ... }`|`ngDoCheck()` | ||||||
|  | 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: | ||||||
| `ngAfterContentInit() { ... }`|`ngAfterContentInit()` | `ngAfterContentInit() { ... }`|`ngAfterContentInit()` | ||||||
|  | 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: | ||||||
| `ngAfterContentChecked() { ... }`|`ngAfterContentChecked()` | `ngAfterContentChecked() { ... }`|`ngAfterContentChecked()` | ||||||
|  | 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: | ||||||
| `ngAfterViewInit() { ... }`|`ngAfterViewInit()` | `ngAfterViewInit() { ... }`|`ngAfterViewInit()` | ||||||
|  | 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: | ||||||
| `ngAfterViewChecked() { ... }`|`ngAfterViewChecked()` | `ngAfterViewChecked() { ... }`|`ngAfterViewChecked()` | ||||||
|  | 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: | ||||||
| `ngOnDestroy() { ... }`|`ngOnDestroy()` | `ngOnDestroy() { ... }`|`ngOnDestroy()` | ||||||
|  | description: | ||||||
| Called once, before the instance is destroyed. | Called once, before the instance is destroyed. | ||||||
| @ -6,50 +6,68 @@ Routing and navigation | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `@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` | ||||||
|  | description: | ||||||
| Configures routes for the decorated component. Supports static, parameterized and wildcard routes. | Configures routes for the decorated component. Supports static, parameterized and wildcard routes. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<router-outlet></router-outlet>`|`router-outlet` | `<router-outlet></router-outlet>`|`router-outlet` | ||||||
|  | description: | ||||||
| Marks the location to load the component of the active route. | Marks the location to load the component of the active route. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<a [router-link]="[ '/MyCmp', {myParam: 'value' } ]">`|`[router-link]` | `<a [router-link]="[ '/MyCmp', {myParam: 'value' } ]">`|`[router-link]` | ||||||
|  | description: | ||||||
| Creates a link to a different view based on a route instruction consisting of a route name and optional parameters. The route name matches the as property of a configured route. Add the '/' prefix to navigate to a root route; add the './' prefix for a child route. | Creates a link to a different view based on a route instruction consisting of a route name and optional parameters. The route name matches the as property of a configured route. Add the '/' prefix to navigate to a root route; add the './' prefix for a child route. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate` | `@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate` | ||||||
|  | description: | ||||||
| A component decorator defining a function that the router should call first to determine if it should activate this component. Should return a boolean or a promise. | A component decorator defining a function that the router should call first to determine if it should activate this component. Should return a boolean or a promise. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate` | `routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate` | ||||||
|  | description: | ||||||
| After navigating to a component, the router calls component's routerOnActivate method (if defined). | After navigating to a component, the router calls component's routerOnActivate method (if defined). | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse` | `routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse` | ||||||
|  | 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 promise. | 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 promise. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse` | `routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse` | ||||||
|  | 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: | ||||||
| `routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate` | `routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate` | ||||||
|  | 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 promise that is resolved. | 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 promise that is resolved. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate` | `routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate` | ||||||
|  | description: | ||||||
| Called before the directive is removed as the result of a route change. May return a promise that pauses removing the directive until the promise resolves. | Called before the directive is removed as the result of a route change. May return a promise that pauses removing the directive until the promise resolves. | ||||||
| @ -4,53 +4,77 @@ Template syntax | |||||||
| @description | @description | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<input [value]="firstName">`|`[value]` | `<input [value]="firstName">`|`[value]` | ||||||
|  | description: | ||||||
| Binds property `value` to the result of expression `firstName`. | Binds property `value` to the result of expression `firstName`. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div [attr.role]="myAriaRole">`|`[attr.role]` | `<div [attr.role]="myAriaRole">`|`[attr.role]` | ||||||
|  | description: | ||||||
| Binds attribute `role` to the result of expression `myAriaRole`. | Binds attribute `role` to the result of expression `myAriaRole`. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div [class.extra-sparkle]="isDelightful">`|`[class.extra-sparkle]` | `<div [class.extra-sparkle]="isDelightful">`|`[class.extra-sparkle]` | ||||||
|  | description: | ||||||
| Binds the presence of the css class `extra-sparkle` on the element to the truthiness of the expression `isDelightful`. | Binds the presence of the css class `extra-sparkle` on the element to the truthiness of the expression `isDelightful`. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div [style.width.px]="mySize">`|`[style.width.px]` | `<div [style.width.px]="mySize">`|`[style.width.px]` | ||||||
|  | description: | ||||||
| Binds style property `width` to the result of expression `mySize` in pixels. Units are optional. | Binds style property `width` to the result of expression `mySize` in pixels. Units are optional. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<button (click)="readRainbow($event)">`|`(click)` | `<button (click)="readRainbow($event)">`|`(click)` | ||||||
|  | description: | ||||||
| Calls method `readRainbow` when a click event is triggered on this button element (or its children) and passes in the event object. | Calls method `readRainbow` when a click event is triggered on this button element (or its children) and passes in the event object. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<div title="Hello {{ponyName}}">`|`{{ponyName}}` | `<div title="Hello {{ponyName}}">`|`{{ponyName}}` | ||||||
|  | description: | ||||||
| Binds a property to an interpolated string, e.g. "Hello Seabiscuit". Equivalent to: | Binds a property to an interpolated string, e.g. "Hello Seabiscuit". Equivalent to: | ||||||
| `<div [title]="'Hello' + ponyName">` | `<div [title]="'Hello' + ponyName">` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<p>Hello {{ponyName}}</p>`|`{{ponyName}}` | `<p>Hello {{ponyName}}</p>`|`{{ponyName}}` | ||||||
|  | description: | ||||||
| Binds text content to an interpolated string, e.g. "Hello Seabiscuit". | Binds text content to an interpolated string, e.g. "Hello Seabiscuit". | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<my-cmp [(title)]="name">`|`[(title)]` | `<my-cmp [(title)]="name">`|`[(title)]` | ||||||
|  | description: | ||||||
| Sets up two-way data binding. Equivalent to: `<my-cmp [title]="name" (title-change)="name=$event">` | Sets up two-way data binding. Equivalent to: `<my-cmp [title]="name" (title-change)="name=$event">` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<video #movieplayer ...> | `<video #movieplayer ...> | ||||||
|   <button (click)="movieplayer.play()"> |   <button (click)="movieplayer.play()"> | ||||||
| </video>`|`#movieplayer`|`(click)` | </video>`|`#movieplayer`|`(click)` | ||||||
|  | description: | ||||||
| Creates a local variable `movieplayer` that provides access to the `video` element instance in data-binding and event-binding expressions in the current template. | Creates a local variable `movieplayer` that provides access to the `video` element instance in data-binding and event-binding expressions in the current template. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<p *my-unless="myExpression">...</p>`|`*my-unless` | `<p *my-unless="myExpression">...</p>`|`*my-unless` | ||||||
|  | description: | ||||||
| The `*` symbol means that the current element will be turned into an embedded template. Equivalent to: | The `*` symbol means that the current element will be turned into an embedded template. Equivalent to: | ||||||
| `<template [myless]="myExpression"><p>...</p></template>` | `<template [myless]="myExpression"><p>...</p></template>` | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<p>Card No.: {{cardNumber | myCreditCardNumberFormatter}}</p>`|`{{cardNumber | myCreditCardNumberFormatter}}` | `<p>Card No.: {{cardNumber | myCreditCardNumberFormatter}}</p>`|`{{cardNumber | myCreditCardNumberFormatter}}` | ||||||
|  | description: | ||||||
| Transforms the current value of expression `cardNumber` via the pipe called `creditCardNumberFormatter`. | Transforms the current value of expression `cardNumber` via the pipe called `creditCardNumberFormatter`. | ||||||
| 
 | 
 | ||||||
| @cheatsheetItem | @cheatsheetItem | ||||||
|  | syntax: | ||||||
| `<p>Employer: {{employer?.companyName}}</p>`|`{{employer?.companyName}}` | `<p>Employer: {{employer?.companyName}}</p>`|`{{employer?.companyName}}` | ||||||
|  | description: | ||||||
| The Elvis operator (`?`) means that the `employer` field is optional and if `undefined`, the rest of the expression should be ignored. | The Elvis operator (`?`) means that the `employer` field is optional and if `undefined`, the rest of the expression should be ignored. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user