|
2 | 2 | Class field decorators for directives and components |
3 | 3 | @cheatsheetIndex 7 |
4 | 4 | @description |
5 | | -{@target js ts}`import {Input, ...} from 'angular2/core';`{@endtarget} |
| 5 | +{@target ts}`import {Input, ...} from 'angular2/core';`{@endtarget} |
| 6 | +{@target js}Available from the `ng.core` namespace{@endtarget} |
6 | 7 | {@target dart}`import 'package:angular2/core.dart';`{@endtarget} |
7 | 8 |
|
8 | 9 | @cheatsheetItem |
9 | | -syntax: |
| 10 | +syntax(ts dart): |
10 | 11 | `@Input() myProperty;`|`@Input()` |
| 12 | +syntax(js): |
| 13 | +`ng.core.Input(myProperty, myComponent);`|`ng.core.Input(`|`);` |
11 | 14 | description: |
12 | 15 | Declares an input property that we can update via property binding (e.g. |
13 | 16 | `<my-cmp [my-property]="someExpression">`). |
14 | 17 |
|
15 | 18 |
|
16 | 19 | @cheatsheetItem |
17 | | -syntax: |
| 20 | +syntax(ts dart): |
18 | 21 | `@Output() myEvent = new EventEmitter();`|`@Output()` |
| 22 | +syntax(js): |
| 23 | +`myEvent = new ng.core.EventEmitter(); ng.core.Output(myEvent, myComponent);`|`ng.core.Output(`|`);` |
19 | 24 | description: |
20 | 25 | Declares an output property that fires events to which we can subscribe with an event binding (e.g. `<my-cmp (my-event)="doSomething()">`). |
21 | 26 |
|
22 | 27 |
|
23 | 28 | @cheatsheetItem |
24 | | -syntax: |
| 29 | +syntax(ts dart): |
25 | 30 | `@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')` |
| 31 | +syntax(js): |
| 32 | +`ng.core.HostBinding('[class.valid]', 'isValid', myComponent);`|`ng.core.HostBinding('[class.valid]', 'isValid'`|`);` |
26 | 33 | description: |
27 | 34 | Binds a host element property (e.g. CSS class valid) to directive/component property (e.g. isValid). |
28 | 35 |
|
29 | 36 |
|
30 | 37 |
|
31 | 38 | @cheatsheetItem |
32 | | -syntax: |
| 39 | +syntax(ts dart): |
33 | 40 | `@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])` |
| 41 | +syntax(js): |
| 42 | +`ng.core.HostListener('click', ['$event'], onClick(e) {...}, myComponent);`|`ng.core.HostListener('click', ['$event'], onClick(e)`|`);` |
34 | 43 | description: |
35 | 44 | Subscribes to a host element event (e.g. click) with a directive/component method (e.g. onClick), optionally passing an argument ($event). |
36 | 45 |
|
37 | 46 |
|
38 | 47 | @cheatsheetItem |
39 | | -syntax: |
| 48 | +syntax(ts dart): |
40 | 49 | `@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)` |
| 50 | +syntax(js): |
| 51 | +`ng.core.ContentChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ContentChild(myPredicate,`|`);` |
41 | 52 | description: |
42 | 53 | Binds the first result of the component content query (myPredicate) to the myChildComponent property of the class. |
43 | 54 |
|
44 | 55 |
|
45 | 56 | @cheatsheetItem |
46 | | -syntax: |
| 57 | +syntax(ts dart): |
47 | 58 | `@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)` |
| 59 | +syntax(js): |
| 60 | +`ng.core.ContentChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ContentChildren(myPredicate,`|`);` |
48 | 61 | description: |
49 | 62 | Binds the results of the component content query (myPredicate) to the myChildComponents property of the class. |
50 | 63 |
|
51 | 64 |
|
52 | 65 | @cheatsheetItem |
53 | | -syntax: |
| 66 | +syntax(ts dart): |
54 | 67 | `@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)` |
| 68 | +syntax(js): |
| 69 | +`ng.core.ViewChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ViewChild(myPredicate,`|`);` |
55 | 70 | description: |
56 | 71 | Binds the first result of the component view query (myPredicate) to the myChildComponent property of the class. Not available for directives. |
57 | 72 |
|
58 | 73 |
|
59 | 74 | @cheatsheetItem |
60 | | -syntax: |
| 75 | +syntax(ts dart): |
61 | 76 | `@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)` |
| 77 | +syntax(js): |
| 78 | +`ng.core.ViewChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ViewChildren(myPredicate,`|`);` |
62 | 79 | description: |
63 | 80 | Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives. |
0 commit comments