Files
Angular-Docs-Cn/modules/angular2/src/core/annotations/view.js
T

70 lines
1.6 KiB
JavaScript
Raw Normal View History

import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang';
2015-03-17 19:22:13 +00:00
/**
2015-03-30 17:19:27 -07:00
* Declare the available HTML templates for an application.
*
* Each angular component requires a single `@Component` and at least one `@View` annotation. The @View
2015-03-30 17:19:27 -07:00
* 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}}!'
2015-03-30 17:19:27 -07:00
* })
* class Greet {
* name: string;
*
* constructor() {
* this.name = 'World';
* }
* }
* ```
*
2015-03-20 21:11:58 +00:00
* @publicModule angular2/annotations
2015-03-17 19:22:13 +00:00
*/
export class View {
templateUrl:any; //string;
template:any; //string;
2014-11-21 21:19:23 -08:00
directives:any; //List<Type>;
formatters:any; //List<Type>;
source:any;//List<View>;
locale:any; //string
device:any; //string
2014-10-02 21:48:46 -07:00
@CONST()
2014-09-25 16:53:32 -07:00
constructor({
templateUrl,
template,
directives,
formatters,
source,
locale,
device
2014-10-02 21:48:46 -07:00
}: {
templateUrl: string,
template: string,
directives: List<Type>,
formatters: List<Type>,
source: List<View>,
locale: string,
device: string
2014-10-02 21:48:46 -07:00
})
{
this.templateUrl = templateUrl;
this.template = template;
2014-10-02 21:48:46 -07:00
this.directives = directives;
this.formatters = formatters;
this.source = source;
this.locale = locale;
this.device = device;
2014-10-02 21:48:46 -07:00
}
}