ViewMetadata

export class ViewMetadata

exported from angular2/core defined in angular2/src/core/metadata/view.ts (line 32)

Metadata properties available for configuring Views.

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 ComponentMetadata.

Example

@Component({ selector: 'greet', template: 'Hello {{name}}!', directives: [GreetUser, Bold] }) class Greet { name: string; constructor() { this.name = 'World'; } }

Constructor

constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls}?: {
  templateUrl?: string,
  template?: string,
  directives?: Array<Type | any[]>,
  pipes?: Array<Type | any[]>,
  encapsulation?: ViewEncapsulation,
  styles?: string[],
  styleUrls?: string[],
})

Not Yet Documented

Members

templateUrl : string

Specifies a template URL for an Angular component.

NOTE: Only one of templateUrl or template can be defined per View.

template : string

Specifies an inline template for an Angular component.

NOTE: Only one of templateUrl or template can be defined per View.

styleUrls : string[]

Specifies stylesheet URLs for an Angular component.

styles : string[]

Specifies an inline stylesheet for an Angular component.

directives : Array<Type | any[]>

Specifies a list of directives that can be used within a template.

Directives must be listed explicitly to provide proper component encapsulation.

#

@Component({ selector: 'my-component', directives: [NgFor] template: ' <ul> <li *ngFor="#item of items">{{item}}</li> </ul>' }) class MyComponent { }

pipes : Array<Type | any[]>

Not Yet Documented

encapsulation : ViewEncapsulation

Specify how the template and the styles should be encapsulated. The default is ViewEncapsulation.Emulated if the view has styles, otherwise ViewEncapsulation.None.