X Tutup
Skip to content

Commit 2f0744b

Browse files
docs(cheatsheet): update to new syntax
See angular/angular.io#459 Closes angular#5733
1 parent ca73852 commit 2f0744b

11 files changed

+120
-5
lines changed

modules/angular2/docs/cheatsheet/bootstrapping.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
Bootstrapping
33
@cheatsheetIndex 0
44
@description
5-
`import {bootstrap} from 'angular2/angular2';`
5+
{@target js ts}`import {bootstrap} from 'angular2/angular2';`{@endtarget}
6+
{@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget}
67

78
@cheatsheetItem
8-
`bootstrap​(MyAppComponent, [MyService, provide(...)]);`
9+
syntax:
10+
`bootstrap​(MyAppComponent, [MyService, provide(...)]);`|`provide`
11+
description:
912
Bootstraps an application with MyAppComponent as the root component and configures the DI providers.

modules/angular2/docs/cheatsheet/built-in-directives.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@ Built-in directives
55
`import {NgIf, ...} from 'angular2/angular2';`
66

77
@cheatsheetItem
8+
syntax:
89
`<section *ng-if="showSection">`|`*ng-if`
10+
description:
911
Removes or recreates a portion of the DOM tree based on the showSection expression.
1012

1113
@cheatsheetItem
14+
syntax:
1215
`<li *ng-for="#item of list">`|`*ng-for`
16+
description:
1317
Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list.
1418

1519
@cheatsheetItem
20+
syntax:
1621
`<div [ng-switch]="conditionExpression">
1722
<template [ng-switch-when]="case1Exp">...</template>
1823
<template ng-switch-when="case2LiteralString">...</template>
1924
<template ng-switch-default>...</template>
2025
</div>`|`[ng-switch]`|`[ng-switch-when]`|`ng-switch-when`|`ng-switch-default`
26+
description:
2127
Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression.
2228

2329
@cheatsheetItem
30+
syntax:
2431
`<div [ng-class]="{active: isActive, disabled: isDisabled}">`|`[ng-class]`
32+
description:
2533
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.

modules/angular2/docs/cheatsheet/class-decorators.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ Class decorators
55
`import {Directive, ...} from 'angular2/angular2';`
66

77
@cheatsheetItem
8+
syntax:
89
`@Component({...})
910
class MyComponent() {}`|`@Component({...})`
11+
description:
1012
Declares that a class is a component and provides metadata about the component.
1113

1214
@cheatsheetItem
15+
syntax:
1316
`@Pipe({...})
1417
class MyPipe() {}`|`@Pipe({...})`
18+
description:
1519
Declares that a class is a pipe and provides metadata about the pipe.
1620

1721
@cheatsheetItem
22+
syntax:
1823
`@Injectable()
1924
class MyService() {}`|`@Injectable()`
25+
description:
2026
Declares that a class has dependencies that should be injected into the constructor when the dependency
2127
injector is creating an instance of this class.

modules/angular2/docs/cheatsheet/component-configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,37 @@ Component configuration
66
so the `@Directive` configuration applies to components as well
77

88
@cheatsheetItem
9+
syntax:
910
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
11+
description:
1012
Array of dependency injection providers scoped to this component's view.
1113

1214

1315
@cheatsheetItem
16+
syntax:
1417
`template: 'Hello {{name}}'
1518
templateUrl: 'my-component.html'`|`template:`|`templateUrl:`
19+
description:
1620
Inline template / external template url of the component's view.
1721

1822

1923
@cheatsheetItem
24+
syntax:
2025
`styles: ['.primary {color: red}']
2126
styleUrls: ['my-component.css']`|`styles:`|`styleUrls:`
27+
description:
2228
List of inline css styles / external stylesheet urls for styling component’s view.
2329

2430

2531
@cheatsheetItem
32+
syntax:
2633
`directives: [MyDirective, MyComponent]`|`directives:`
34+
description:
2735
List of directives used in the the component’s template.
2836

2937

3038
@cheatsheetItem
39+
syntax:
3140
`pipes: [MyPipe, OtherPipe]`|`pipes:`
41+
description:
3242
List of pipes used in the component's template.

modules/angular2/docs/cheatsheet/dependency-injection.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ Dependency injection configuration
55
`import {provide} from 'angular2/angular2';`
66

77
@cheatsheetItem
8-
`provide(MyService, {useClass: MyMockService})``provide`|`useClass`
8+
syntax:
9+
`provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
10+
description:
911
Sets or overrides the provider for MyService to the MyMockService class.
1012

1113

1214
@cheatsheetItem
13-
`provide(MyService, {useFactory: myFactory})``provide`|`useFactory`
15+
syntax:
16+
`provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
17+
description:
1418
Sets or overrides the provider for MyService to the myFactory factory function.
1519

1620

1721
@cheatsheetItem
18-
`provide(MyValue, {useValue: 41})``provide`|`useValue`
22+
syntax:
23+
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
24+
description:
1925
Sets or overrides the provider for MyValue to the value 41.
2026

modules/angular2/docs/cheatsheet/directive-and-component-decorators.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,58 @@ Class field decorators for directives and components
55
`import {Input, ...} from 'angular2/angular2';`
66

77
@cheatsheetItem
8+
syntax:
89
`@Input() myProperty;`|`@Input()`
10+
description:
911
Declares an input property that we can update via property binding, e.g.
1012
`<my-cmp [my-property]="someExpression">`
1113

1214

1315
@cheatsheetItem
16+
syntax:
1417
`@Output() myEvent = new EventEmitter();`|`@Output()`
18+
description:
1519
Declares an output property that fires events to which we can subscribe with an event binding, e.g. `<my-cmp (my-event)="doSomething()">`
1620

1721

1822
@cheatsheetItem
23+
syntax:
1924
`@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')`
25+
description:
2026
Binds a host element property (e.g. css class valid) to directive/component property (e.g. isValid)
2127

2228

2329

2430
@cheatsheetItem
31+
syntax:
2532
`@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])`
33+
description:
2634
Subscribes to a host element event (e.g. click) with a directive/component method (e.g., onClick), optionally passing an argument ($event)
2735

2836

2937
@cheatsheetItem
38+
syntax:
3039
`@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)`
40+
description:
3141
Binds the first result of the component content query (myPredicate) to the myChildComponent property of the class.
3242

3343

3444
@cheatsheetItem
45+
syntax:
3546
`@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)`
47+
description:
3648
Binds the results of the component content query (myPredicate) to the myChildComponents property of the class.
3749

3850

3951
@cheatsheetItem
52+
syntax:
4053
`@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)`
54+
description:
4155
Binds the first result of the component view query (myPredicate) to the myChildComponent property of the class. Not available for directives.
4256

4357

4458
@cheatsheetItem
59+
syntax:
4560
`@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)`
61+
description:
4662
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.

modules/angular2/docs/cheatsheet/directive-configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ Directive configuration
55
`@Directive({ property1: value1, ... }) )`
66

77
@cheatsheetItem
8+
syntax:
89
`selector: '.cool-button:not(a)'`|`selector:`
10+
description:
911
Specifies a css selector that identifies this directive within a template. Supported selectors include: `element`,
1012
`[attribute]`, `.class`, and `:not()`.
1113

1214
Does not support parent-child relationship selectors.
1315

1416
@cheatsheetItem
17+
syntax:
1518
`providers: [MyService, provide(...)]`|`providers:`
19+
description:
1620
Array of dependency injection providers for this directive and its children.

modules/angular2/docs/cheatsheet/forms.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ Forms
55
`import {FORM_DIRECTIVES} from 'angular2/angular2';`
66

77
@cheatsheetItem
8+
syntax:
89
`<input [(ng-model)]="userName">`|`[(ng-model)]`
10+
description:
911
Provides two-way data-binding, parsing and validation for form controls.

modules/angular2/docs/cheatsheet/lifecycle hooks.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,63 @@ Directive and component change detection and lifecycle hooks
55
(implemented as class methods)
66

77
@cheatsheetItem
8+
syntax:
89
`constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)`
10+
description:
911
The class constructor is called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
1012

1113

1214
@cheatsheetItem
15+
syntax:
1316
`ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)`
17+
description:
1418
Called after every change to input properties and before processing content or child views.
1519

1620

1721
@cheatsheetItem
22+
syntax:
1823
`ngOnInit() { ... }`|`ngOnInit()`
24+
description:
1925
Called after the constructor, initializing input properties, and the first call to ngOnChanges.
2026

2127

2228
@cheatsheetItem
29+
syntax:
2330
`ngDoCheck() { ... }`|`ngDoCheck()`
31+
description:
2432
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.
2533

2634

2735
@cheatsheetItem
36+
syntax:
2837
`ngAfterContentInit() { ... }`|`ngAfterContentInit()`
38+
description:
2939
Called after ngOnInit when the component's or directive's content has been initialized.
3040

3141

3242
@cheatsheetItem
43+
syntax:
3344
`ngAfterContentChecked() { ... }`|`ngAfterContentChecked()`
45+
description:
3446
Called after every check of the component's or directive's content.
3547

3648

3749
@cheatsheetItem
50+
syntax:
3851
`ngAfterViewInit() { ... }`|`ngAfterViewInit()`
52+
description:
3953
Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
4054

4155

4256
@cheatsheetItem
57+
syntax:
4358
`ngAfterViewChecked() { ... }`|`ngAfterViewChecked()`
59+
description:
4460
Called after every check of the component's view. Applies to components only.
4561

4662

4763
@cheatsheetItem
64+
syntax:
4865
`ngOnDestroy() { ... }`|`ngOnDestroy()`
66+
description:
4967
Called once, before the instance is destroyed.

modules/angular2/docs/cheatsheet/routing.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,68 @@ Routing and navigation
66

77

88
@cheatsheetItem
9+
syntax:
910
`@RouteConfig([
1011
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
1112
{ path: '/staticPath', component: ..., as: ...},
1213
{ path: '/*wildCardParam', component: ..., as: ...}
1314
])
1415
class MyComponent() {}`|`@RouteConfig`
16+
description:
1517
Configures routes for the decorated component. Supports static, parameterized and wildcard routes.
1618

1719

1820
@cheatsheetItem
21+
syntax:
1922
`<router-outlet></router-outlet>`|`router-outlet`
23+
description:
2024
Marks the location to load the component of the active route.
2125

2226

2327
@cheatsheetItem
28+
syntax:
2429
`<a [router-link]="[ '/MyCmp', {myParam: 'value' } ]">`|`[router-link]`
30+
description:
2531
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.
2632

2733

2834
@cheatsheetItem
35+
syntax:
2936
`@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate`
37+
description:
3038
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.
3139

3240

3341
@cheatsheetItem
42+
syntax:
3443
`routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
44+
description:
3545
After navigating to a component, the router calls component's routerOnActivate method (if defined).
3646

3747

3848
@cheatsheetItem
49+
syntax:
3950
`routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
51+
description:
4052
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.
4153

4254

4355
@cheatsheetItem
56+
syntax:
4457
`routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
58+
description:
4559
The router calls the component's routerOnReuse method (if defined) when it re-uses a component instance.
4660

4761

4862
@cheatsheetItem
63+
syntax:
4964
`routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
65+
description:
5066
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.
5167

5268

5369
@cheatsheetItem
70+
syntax:
5471
`routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
72+
description:
5573
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.

0 commit comments

Comments
 (0)
X Tutup