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

32 lines
925 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@cheatsheetSection
Component configuration
@cheatsheetIndex 6
@description
`@Component` extends `@Directive`,
so the `@Directive` configuration applies to components as well
@cheatsheetItem
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
Array of dependency injection providers scoped to this component's view.
@cheatsheetItem
`template: 'Hello {{name}}'
templateUrl: 'my-component.html'`|`template:`|`templateUrl:`
Inline template / external template url of the component's view.
@cheatsheetItem
`styles: ['.primary {color: red}']
styleUrls: ['my-component.css']`|`styles:`|`styleUrls:`
List of inline css styles / external stylesheet urls for styling components view.
@cheatsheetItem
`directives: [MyDirective, MyComponent]`|`directives:`
List of directives used in the the components template.
@cheatsheetItem
`pipes: [MyPipe, OtherPipe]`|`pipes:`
List of pipes used in the component's template.