2015-02-05 13:08:05 -08:00
|
|
|
import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang';
|
2014-09-19 16:38:37 -07:00
|
|
|
|
2015-03-17 19:22:13 +00:00
|
|
|
/**
|
2015-03-30 17:19:27 -07:00
|
|
|
* Declare the available HTML templates for an application.
|
|
|
|
*
|
2015-04-09 21:20:11 +02:00
|
|
|
* 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'
|
|
|
|
* })
|
2015-04-09 21:20:11 +02:00
|
|
|
* @View({
|
2015-04-10 11:15:01 -07:00
|
|
|
* template: 'Hello {{name}}!',
|
|
|
|
* directives: [GreetUser, Bold]
|
2015-03-30 17:19:27 -07:00
|
|
|
* })
|
|
|
|
* class Greet {
|
|
|
|
* name: string;
|
|
|
|
*
|
|
|
|
* constructor() {
|
|
|
|
* this.name = 'World';
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
2015-04-10 12:45:02 +02:00
|
|
|
* @exportedAs angular2/annotations
|
2015-03-17 19:22:13 +00:00
|
|
|
*/
|
2015-04-09 21:20:11 +02:00
|
|
|
export class View {
|
2015-04-15 22:35:38 +00:00
|
|
|
/**
|
|
|
|
* Specify a template URL for an angular component.
|
|
|
|
*
|
|
|
|
* NOTE: either `templateURL` or `template` should be used, but not both.
|
|
|
|
*/
|
2015-04-09 21:20:11 +02:00
|
|
|
templateUrl:any; //string;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify an inline template for an angular component.
|
|
|
|
*
|
|
|
|
* NOTE: either `templateURL` or `template` should be used, but not both.
|
|
|
|
*/
|
2015-04-09 21:20:11 +02:00
|
|
|
template:any; //string;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specify a list of directives that are active within a template. [TODO: true?]
|
|
|
|
*
|
|
|
|
* Directives must be listed explicitly to provide proper component encapsulation.
|
|
|
|
*
|
|
|
|
* ## Example
|
|
|
|
*
|
|
|
|
* ```javascript
|
|
|
|
* @Component({
|
|
|
|
* selector: 'my-component'
|
|
|
|
* })
|
|
|
|
* @View({
|
|
|
|
* directives: [For]
|
|
|
|
* template: '
|
|
|
|
* <ul>
|
|
|
|
* <li *for="item in items">{{item}}</li>
|
|
|
|
* </ul>'
|
|
|
|
* })
|
|
|
|
* class MyComponent {
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2014-11-21 21:19:23 -08:00
|
|
|
directives:any; //List<Type>;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
2014-10-02 21:48:46 -07:00
|
|
|
@CONST()
|
2014-09-25 16:53:32 -07:00
|
|
|
constructor({
|
2015-04-09 21:20:11 +02:00
|
|
|
templateUrl,
|
|
|
|
template,
|
2015-04-15 22:35:38 +00:00
|
|
|
directives
|
2014-10-02 21:48:46 -07:00
|
|
|
}: {
|
2015-04-09 21:20:11 +02:00
|
|
|
templateUrl: string,
|
|
|
|
template: string,
|
2015-04-15 22:35:38 +00:00
|
|
|
directives: List<Type>
|
2014-10-02 21:48:46 -07:00
|
|
|
})
|
|
|
|
{
|
2015-04-09 21:20:11 +02:00
|
|
|
this.templateUrl = templateUrl;
|
|
|
|
this.template = template;
|
2014-10-02 21:48:46 -07:00
|
|
|
this.directives = directives;
|
|
|
|
}
|
|
|
|
}
|