X Tutup
Skip to content

Commit f4d937a

Browse files
committed
docs(cheatsheet): add Dart-specific syntax & headings
Closes angular#5756
1 parent db096a5 commit f4d937a

File tree

8 files changed

+44
-20
lines changed

8 files changed

+44
-20
lines changed

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

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

78
@cheatsheetItem
89
syntax:
@@ -30,4 +31,4 @@ Conditionally swaps the contents of the div by selecting one of the embedded tem
3031
syntax:
3132
`<div [ng-class]="{active: isActive, disabled: isDisabled}">`|`[ng-class]`
3233
description:
33-
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.
34+
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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,36 @@
22
Class decorators
33
@cheatsheetIndex 4
44
@description
5-
`import {Directive, ...} from 'angular2/angular2';`
5+
{@target js ts}`import {Directive, ...} from 'angular2/angular2';`{@endtarget}
6+
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
67

78
@cheatsheetItem
8-
syntax:
9+
syntax(js ts):
910
`@Component({...})
1011
class MyComponent() {}`|`@Component({...})`
12+
syntax(dart):
13+
`@Component(...)
14+
class MyComponent() {}`|`@Component(...)`
1115
description:
1216
Declares that a class is a component and provides metadata about the component.
1317

1418
@cheatsheetItem
15-
syntax:
19+
syntax(js ts):
1620
`@Pipe({...})
1721
class MyPipe() {}`|`@Pipe({...})`
22+
syntax(dart):
23+
`@Pipe(...)
24+
class MyPipe() {}`|`@Pipe(...)`
1825
description:
1926
Declares that a class is a pipe and provides metadata about the pipe.
2027

2128
@cheatsheetItem
22-
syntax:
29+
syntax(js ts):
30+
`@Injectable()
31+
class MyService() {}`|`@Injectable()`
32+
syntax(dart):
2333
`@Injectable()
2434
class MyService() {}`|`@Injectable()`
2535
description:
2636
Declares that a class has dependencies that should be injected into the constructor when the dependency
27-
injector is creating an instance of this class.
37+
injector is creating an instance of this class.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Dependency injection configuration
33
@cheatsheetIndex 9
44
@description
5-
`import {provide} from 'angular2/angular2';`
5+
{@target js ts}`import {provide} from 'angular2/angular2';`{@endtarget}
6+
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
67

78
@cheatsheetItem
89
syntax:

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Class field decorators for directives and components
33
@cheatsheetIndex 7
44
@description
5-
`import {Input, ...} from 'angular2/angular2';`
5+
{@target js ts}`import {Input, ...} from 'angular2/angular2';`{@endtarget}
6+
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
67

78
@cheatsheetItem
89
syntax:
@@ -59,4 +60,4 @@ Binds the first result of the component view query (myPredicate) to the myChildC
5960
syntax:
6061
`@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)`
6162
description:
62-
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.
63+
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Directive configuration
33
@cheatsheetIndex 5
44
@description
5-
`@Directive({ property1: value1, ... }) )`
5+
{@target js ts}`@Directive({ property1: value1, ... })`{@endtarget}
6+
{@target dart}`@Directive(property1: value1, ...)`{@endtarget}
67

78
@cheatsheetItem
89
syntax:
@@ -17,4 +18,4 @@ Does not support parent-child relationship selectors.
1718
syntax:
1819
`providers: [MyService, provide(...)]`|`providers:`
1920
description:
20-
Array of dependency injection providers for this directive and its children.
21+
Array of dependency injection providers for this directive and its children.

modules/angular2/docs/cheatsheet/forms.md

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

78
@cheatsheetItem
89
syntax:
910
`<input [(ng-model)]="userName">`|`[(ng-model)]`
1011
description:
11-
Provides two-way data-binding, parsing and validation for form controls.
12+
Provides two-way data-binding, parsing and validation for form controls.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Directive and component change detection and lifecycle hooks
55
(implemented as class methods)
66

77
@cheatsheetItem
8-
syntax:
8+
syntax(js ts):
99
`constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)`
10+
syntax(dart):
11+
`MyAppComponent(MyService myService, ...) { ... }`|`MyAppComponent(MyService myService, ...)`
1012
description:
1113
The class constructor is called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
1214

@@ -64,4 +66,4 @@ Called after every check of the component's view. Applies to components only.
6466
syntax:
6567
`ngOnDestroy() { ... }`|`ngOnDestroy()`
6668
description:
67-
Called once, before the instance is destroyed.
69+
Called once, before the instance is destroyed.

modules/angular2/docs/cheatsheet/routing.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
Routing and navigation
33
@cheatsheetIndex 10
44
@description
5-
`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`
5+
{@target js ts}`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`{@endtarget}
6+
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
67

78

89
@cheatsheetItem
9-
syntax:
10+
syntax(js ts):
1011
`@RouteConfig([
1112
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
1213
{ path: '/staticPath', component: ..., as: ...},
1314
{ path: '/*wildCardParam', component: ..., as: ...}
1415
])
1516
class MyComponent() {}`|`@RouteConfig`
17+
syntax(dart):
18+
`@RouteConfig(const [
19+
const Route(path: '/:myParam', component: MyComponent, name: 'MyCmp' ),
20+
])`
1621
description:
1722
Configures routes for the decorated component. Supports static, parameterized and wildcard routes.
1823

@@ -32,8 +37,10 @@ Creates a link to a different view based on a route instruction consisting of a
3237

3338

3439
@cheatsheetItem
35-
syntax:
40+
syntax(js ts):
3641
`@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate`
42+
syntax(dart):
43+
`@CanActivate(() => ...)class MyComponent() {}`|`@CanActivate`
3744
description:
3845
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.
3946

@@ -70,4 +77,4 @@ The router calls the routerCanDeactivate methods (if defined) of every component
7077
syntax:
7178
`routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
7279
description:
73-
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.
80+
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