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-04-17 13:01:07 -07:00
|
|
|
* Declares the available HTML templates for an application.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
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.
|
|
|
|
*
|
2015-04-17 13:01:07 -07:00
|
|
|
* For details on the `@Component` annotation, see {@link Component}.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
|
|
|
* ## 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
|
|
|
/**
|
2015-04-17 13:01:07 -07:00
|
|
|
* Specifies a template URL for an angular component.
|
2015-04-15 22:35:38 +00:00
|
|
|
*
|
|
|
|
* NOTE: either `templateURL` or `template` should be used, but not both.
|
|
|
|
*/
|
2015-04-19 14:47:02 -07:00
|
|
|
templateUrl:string;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-17 13:01:07 -07:00
|
|
|
* Specifies an inline template for an angular component.
|
2015-04-15 22:35:38 +00:00
|
|
|
*
|
|
|
|
* NOTE: either `templateURL` or `template` should be used, but not both.
|
|
|
|
*/
|
2015-04-19 14:47:02 -07:00
|
|
|
template:string;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-17 13:01:07 -07:00
|
|
|
* Specifies a list of directives that can be used within a template.
|
2015-04-15 22:35:38 +00:00
|
|
|
*
|
|
|
|
* 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 {
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2015-04-19 14:47:02 -07:00
|
|
|
directives:List<Type>;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
2015-04-20 11:34:53 -07:00
|
|
|
/**
|
|
|
|
* Specify a custom renderer for this View.
|
|
|
|
* If this is set, neither `template`, `templateURL` nor `directives` are used.
|
|
|
|
*/
|
|
|
|
renderer:any; // string;
|
|
|
|
|
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-20 11:34:53 -07:00
|
|
|
directives,
|
|
|
|
renderer
|
2014-10-02 21:48:46 -07:00
|
|
|
}: {
|
2015-04-09 21:20:11 +02:00
|
|
|
templateUrl: string,
|
|
|
|
template: string,
|
2015-04-20 11:34:53 -07:00
|
|
|
directives: List<Type>,
|
|
|
|
renderer: string
|
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;
|
2015-04-20 11:34:53 -07:00
|
|
|
this.renderer = renderer;
|
2014-10-02 21:48:46 -07:00
|
|
|
}
|
|
|
|
}
|