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

47 lines
1.3 KiB
Markdown
Raw Normal View History

2015-11-06 07:26:24 -05:00
@cheatsheetSection
Component configuration
@cheatsheetIndex 6
2015-11-05 10:04:55 -05:00
@description
{@target js}`ng.core.Component` extends `ng.core.Directive`,
so the `ng.core.Directive` configuration applies to components as well{@endtarget}
{@target ts dart}`@Component` extends `@Directive`,
so the `@Directive` configuration applies to components as well{@endtarget}
2015-11-05 10:04:55 -05:00
@cheatsheetItem
syntax(ts dart):
2015-11-05 10:04:55 -05:00
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
syntax(js):
`viewProviders: [MyService, ng.core.provide(...)]`|`viewProviders:`
description:
2015-11-05 10:04:55 -05:00
Array of dependency injection providers scoped to this component's view.
@cheatsheetItem
syntax:
2015-11-06 07:26:24 -05:00
`template: 'Hello {{name}}'
templateUrl: 'my-component.html'`|`template:`|`templateUrl:`
description:
Inline template / external template URL of the component's view.
2015-11-05 10:04:55 -05:00
@cheatsheetItem
syntax:
2015-11-06 07:26:24 -05:00
`styles: ['.primary {color: red}']
styleUrls: ['my-component.css']`|`styles:`|`styleUrls:`
description:
List of inline CSS styles / external stylesheet URLs for styling components view.
2015-11-05 10:04:55 -05:00
@cheatsheetItem
syntax:
2015-11-05 10:04:55 -05:00
`directives: [MyDirective, MyComponent]`|`directives:`
description:
2015-11-05 10:04:55 -05:00
List of directives used in the the components template.
@cheatsheetItem
syntax:
2015-11-05 10:04:55 -05:00
`pipes: [MyPipe, OtherPipe]`|`pipes:`
description:
List of pipes used in the component's template.