Deprecation Notes
Use ComponentMetadata instead.
Class Overview
class ViewMetadata {
constructor
({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls, animations, interpolation}?: { templateUrl?: string, template?: string, directives?: Array<Type|any[]>, pipes?: Array<Type|any[]>, encapsulation?: ViewEncapsulation, styles?: string[], styleUrls?: string[], animations?: AnimationEntryMetadata[], interpolation?: [string, string] })
templateUrl
: string
template
: string
styleUrls
: string[]
styles
: string[]
directives
: Array<Type|any[]>
pipes
: Array<Type|any[]>
encapsulation
: ViewEncapsulation
animations
: AnimationEntryMetadata[]
interpolation
: [string, string]
}
Class Description
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';
}
}
Class Export
export class ViewMetadata
Constructor
constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls, animations,
interpolation}?: {
templateUrl?: string,
template?: string,
directives?: Array<Type|any[]>,
pipes?: Array<Type|any[]>,
encapsulation?: ViewEncapsulation,
styles?: string[],
styleUrls?: string[],
animations?: AnimationEntryMetadata[],
interpolation?: [string, string]
})
Class Details
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="let item of items">{{item}}</li>
</ul>'
})
class MyComponent {
}
pipes : Array<Type|any[]>
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
.
animations : AnimationEntryMetadata[]
interpolation : [string, string]
exported from @angular/core/index defined in @angular/core/src/metadata/view.ts (line 43)