2015-11-06 12:26:24 +00:00
@cheatsheetSection
Class decorators
2016-08-08 17:18:50 -07:00
@cheatsheetIndex 5
2015-11-05 15:04:55 +00:00
@description
2016-08-09 02:25:42 +02:00
{@target ts}`import { Directive, ... } from '@angular/core';` {@endtarget }
2015-12-12 21:17:26 -06:00
{@target js}Available from the `ng.core` namespace{@endtarget }
2016-04-01 13:03:10 -07:00
{@target dart}`import 'package:angular2/core.dart';` {@endtarget }
2015-11-05 15:04:55 +00:00
@cheatsheetItem
2015-12-12 21:17:26 -06:00
syntax(ts):
2015-11-05 15:04:55 +00:00
`@Component({...})
class MyComponent() {}` |`@Component({...})`
2015-12-12 21:17:26 -06:00
syntax(js):
`var MyComponent = ng.core.Component({...}).Class({...})` |`ng.core.Component({...})`
2015-12-09 10:22:40 -08:00
syntax(dart):
`@Component(...)
class MyComponent() {}` |`@Component(...)`
2015-12-09 12:33:42 +00:00
description:
2015-11-05 15:04:55 +00:00
Declares that a class is a component and provides metadata about the component.
2016-04-21 15:16:51 +02:00
@cheatsheetItem
syntax(ts):
`@Directive({...})
class MyDirective() {}` |`@Directive({...})`
syntax(js):
`var MyDirective = ng.core.Directive({...}).Class({...})` |`ng.core.Directive({...})`
syntax(dart):
`@Directive(...)
class MyDirective() {}` |`@Directive(...)`
description:
Declares that a class is a directive and provides metadata about the directive.
2015-11-05 15:04:55 +00:00
@cheatsheetItem
2015-12-12 21:17:26 -06:00
syntax(ts):
2015-11-05 15:04:55 +00:00
`@Pipe({...})
class MyPipe() {}` |`@Pipe({...})`
2015-12-12 21:17:26 -06:00
syntax(js):
`var MyPipe = ng.core.Pipe({...}).Class({...})` |`ng.core.Pipe({...})`
2015-12-09 10:22:40 -08:00
syntax(dart):
`@Pipe(...)
class MyPipe() {}` |`@Pipe(...)`
2015-12-09 12:33:42 +00:00
description:
2015-11-05 15:04:55 +00:00
Declares that a class is a pipe and provides metadata about the pipe.
@cheatsheetItem
2015-12-12 21:17:26 -06:00
syntax(ts):
2015-12-09 10:22:40 -08:00
`@Injectable()
class MyService() {}` |`@Injectable()`
2015-12-12 21:17:26 -06:00
syntax(js):
2015-12-15 01:27:19 -08:00
`var OtherService = ng.core.Class({constructor: function() { }});
var MyService = ng.core.Class({constructor: [OtherService, function(otherService) { }]});` |`var MyService = ng.core.Class({constructor: [OtherService, function(otherService) { }]});`
2015-12-09 10:22:40 -08:00
syntax(dart):
2015-11-05 15:04:55 +00:00
`@Injectable()
class MyService() {}` |`@Injectable()`
2015-12-09 12:33:42 +00:00
description:
2015-12-12 21:17:26 -06:00
{@target ts dart}Declares that a class has dependencies that should be injected into the constructor when the dependency injector is creating an instance of this class.
{@endtarget }
{@target js}
Declares a service to inject into a class by providing an array with the services with the final item being the function which will receive the injected services.
{@endtarget }