2015-02-05 13:08:05 -08:00
|
|
|
import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang';
|
2015-07-24 15:28:44 -07:00
|
|
|
import {ViewEncapsulation} from 'angular2/src/render/api';
|
|
|
|
|
|
|
|
export {ViewEncapsulation} from 'angular2/src/render/api';
|
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-05-20 09:48:15 -07:00
|
|
|
* Each angular component requires a single `@Component` and at least one `@View` annotation. The
|
2015-06-01 21:36:06 -07:00
|
|
|
* `@View` annotation specifies the HTML template to use, and lists the directives that are active
|
|
|
|
* within the template.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
2015-05-20 09:48:15 -07:00
|
|
|
* When a component is instantiated, the template is loaded into the component's shadow root, and
|
2015-06-01 21:36:06 -07:00
|
|
|
* the expressions and statements in the template are evaluated against the component.
|
2015-03-30 17:19:27 -07:00
|
|
|
*
|
2015-08-14 10:03:45 -07:00
|
|
|
* For details on the `@Component` annotation, see {@link ComponentMetadata}.
|
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-03-17 19:22:13 +00:00
|
|
|
*/
|
2015-05-20 09:48:15 -07:00
|
|
|
@CONST()
|
2015-08-14 10:03:45 -07:00
|
|
|
export class ViewMetadata {
|
2015-07-07 22:09:19 +02:00
|
|
|
/**
|
2015-08-02 10:30:00 +03:00
|
|
|
* Specifies a template URL for an angular component.
|
2015-07-07 22:09:19 +02:00
|
|
|
*
|
|
|
|
* NOTE: either `templateUrl` or `template` should be used, but not both.
|
|
|
|
*/
|
2015-07-06 16:32:29 -07:00
|
|
|
templateUrl: string;
|
|
|
|
|
2015-04-15 22:35:38 +00:00
|
|
|
/**
|
2015-08-02 10:30:00 +03:00
|
|
|
* Specifies an inline template for an angular component.
|
2015-04-15 22:35:38 +00:00
|
|
|
*
|
2015-04-21 21:01:22 -07:00
|
|
|
* NOTE: either `templateUrl` or `template` should be used, but not both.
|
2015-04-15 22:35:38 +00:00
|
|
|
*/
|
2015-07-07 22:09:19 +02:00
|
|
|
template: string;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-07 22:09:19 +02:00
|
|
|
* Specifies stylesheet URLs for an angular component.
|
2015-04-15 22:35:38 +00:00
|
|
|
*/
|
2015-07-07 22:09:19 +02:00
|
|
|
styleUrls: List<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies an inline stylesheet for an angular component.
|
|
|
|
*/
|
|
|
|
styles: List<string>;
|
2015-06-10 14:40:24 +02:00
|
|
|
|
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>
|
2015-05-13 11:30:59 +02:00
|
|
|
* <li *ng-for="#item of items">{{item}}</li>
|
2015-04-15 22:35:38 +00:00
|
|
|
* </ul>'
|
|
|
|
* })
|
|
|
|
* class MyComponent {
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-07 22:09:19 +02:00
|
|
|
// TODO(tbosch): use Type | Binding | List<any> when Dart supports union types,
|
|
|
|
// as otherwise we would need to import Binding type and Dart would warn
|
|
|
|
// for an unused import.
|
|
|
|
directives: List<Type | any | List<any>>;
|
2015-04-15 22:35:38 +00:00
|
|
|
|
2015-08-07 11:41:38 -07:00
|
|
|
pipes: List<Type | any | List<any>>;
|
|
|
|
|
2015-04-20 11:34:53 -07:00
|
|
|
/**
|
2015-07-24 15:28:44 -07:00
|
|
|
* Specify how the template and the styles should be encapsulated.
|
2015-08-02 22:29:05 -07:00
|
|
|
* The default is {@link ViewEncapsulation#EMULATED `ViewEncapsulation.EMULATED`} if the view
|
|
|
|
* has styles,
|
|
|
|
* otherwise {@link ViewEncapsulation#NONE `ViewEncapsulation.NONE`}.
|
2015-04-20 11:34:53 -07:00
|
|
|
*/
|
2015-07-24 15:28:44 -07:00
|
|
|
encapsulation: ViewEncapsulation;
|
2015-07-06 16:32:29 -07:00
|
|
|
|
2015-08-07 11:41:38 -07:00
|
|
|
constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls}: {
|
2015-07-07 22:09:19 +02:00
|
|
|
templateUrl?: string,
|
|
|
|
template?: string,
|
|
|
|
directives?: List<Type | any | List<any>>,
|
2015-08-07 11:41:38 -07:00
|
|
|
pipes?: List<Type | any | List<any>>,
|
2015-07-24 15:28:44 -07:00
|
|
|
encapsulation?: ViewEncapsulation,
|
2015-07-07 22:09:19 +02:00
|
|
|
styles?: List<string>,
|
|
|
|
styleUrls?: List<string>,
|
|
|
|
} = {}) {
|
|
|
|
this.templateUrl = templateUrl;
|
|
|
|
this.template = template;
|
|
|
|
this.styleUrls = styleUrls;
|
|
|
|
this.styles = styles;
|
|
|
|
this.directives = directives;
|
2015-08-07 11:41:38 -07:00
|
|
|
this.pipes = pipes;
|
2015-07-24 15:28:44 -07:00
|
|
|
this.encapsulation = encapsulation;
|
2015-07-07 22:09:19 +02:00
|
|
|
}
|
2015-06-12 23:51:42 -07:00
|
|
|
}
|