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

38 lines
1007 B
Markdown
Raw Normal View History

2015-11-06 07:26:24 -05:00
@cheatsheetSection
Class decorators
@cheatsheetIndex 4
2015-11-05 10:04:55 -05:00
@description
{@target js ts}`import {Directive, ...} from 'angular2/core';`{@endtarget}
{@target dart}`import 'package:angular2/core.dart';`{@endtarget}
2015-11-05 10:04:55 -05:00
@cheatsheetItem
syntax(js ts):
2015-11-05 10:04:55 -05:00
`@Component({...})
class MyComponent() {}`|`@Component({...})`
syntax(dart):
`@Component(...)
class MyComponent() {}`|`@Component(...)`
description:
2015-11-05 10:04:55 -05:00
Declares that a class is a component and provides metadata about the component.
@cheatsheetItem
syntax(js ts):
2015-11-05 10:04:55 -05:00
`@Pipe({...})
class MyPipe() {}`|`@Pipe({...})`
syntax(dart):
`@Pipe(...)
class MyPipe() {}`|`@Pipe(...)`
description:
2015-11-05 10:04:55 -05:00
Declares that a class is a pipe and provides metadata about the pipe.
@cheatsheetItem
syntax(js ts):
`@Injectable()
class MyService() {}`|`@Injectable()`
syntax(dart):
2015-11-05 10:04:55 -05:00
`@Injectable()
class MyService() {}`|`@Injectable()`
description:
2015-11-05 10:04:55 -05:00
Declares that a class has dependencies that should be injected into the constructor when the dependency
injector is creating an instance of this class.