p.
exported from angular2/annotations
defined in angular2/src/core/annotations/view.js (line 34)
:markdown
Declares the available HTML templates for an application.
Each angular component requires a single `@Component` and at least one `@View` annotation. The @View
annotation specifies the HTML template to use, and lists the directives that are active within the template.
When a component is instantiated, the template is loaded into the component's shadow root, and the
expressions and statements in the template are evaluated against the component.
For details on the `@Component` annotation, see Component
.
## Example
```
@Component({
selector: 'greet'
})
@View({
template: 'Hello {{name}}!',
directives: [GreetUser, Bold]
})
class Greet {
name: string;
constructor() {
this.name = 'World';
}
}
```
.l-main-section
h2 Members
.l-sub-section
h3 constructor
pre.prettyprint
code.
constructor({
templateUrl,
template,
directives,
renderer
}: {
templateUrl: string,
template: string,
directives: List<Type>,
renderer: string
})
:markdown
.l-sub-section
h3 directives
:markdown
Specifies a list of directives that can be used within a template.
Directives must be listed explicitly to provide proper component encapsulation.
```javascript
@Component({
selector: 'my-component'
})
@View({
directives: [For]
template: '