chore(core): remove @View annotation

Closes #7495
This commit is contained in:
Brian Ford 2016-03-08 13:36:48 -08:00
parent 095db673c5
commit f9fb72fb0e
85 changed files with 588 additions and 599 deletions

View File

@ -117,7 +117,7 @@ speed things up is to use plain class fields in your expressions and avoid any
kinds of computation. Example: kinds of computation. Example:
```typescript ```typescript
@View({ @Component({
template: '<button [enabled]="isEnabled">{{title}}</button>' template: '<button [enabled]="isEnabled">{{title}}</button>'
}) })
class FancyButton { class FancyButton {

View File

@ -112,9 +112,7 @@ Example of a component:
'title', | - title mapped to component title 'title', | - title mapped to component title
'open' | - open attribute mapped to component's open property 'open' | - open attribute mapped to component's open property
], | ], |
}) | templateUrl: 'pane.html' | URL of template HTML
@View({ | View annotation
templateUrl: 'pane.html' | - URL of template HTML
}) | }) |
class Pane { | Component controller class class Pane { | Component controller class
title:string; | - title property title:string; | - title property
@ -227,11 +225,9 @@ class MyService {} | Assume a service which needs to be inject
| |
@Component({ | Assume a top level application component which @Component({ | Assume a top level application component which
selector: 'my-app', | configures the services to be injected. selector: 'my-app', | configures the services to be injected.
viewBindings: [MyService] | viewBindings: [MyService], |
}) | templateUrl: 'my_app.html', | Assume we have a template that needs to be
@View({ | Assume we have a template that needs to be directives: [House] | configured with directives to be injected.
templateUrl: 'my_app.html', | configured with directives to be injected.
directives: [House] |
}) | }) |
class MyApp {} | class MyApp {} |
| |
@ -273,8 +269,6 @@ Here is an example of the kinds of injections which can be achieved:
``` ```
@Component({ | @Component({ |
selector: 'my-app' | selector: 'my-app' |
}) |
@View({ |
templateUrl: 'my_app.html', | templateUrl: 'my_app.html', |
directives: [Form, FieldSet, | directives: [Form, FieldSet, |
Field, Primary] | Field, Primary] |
@ -329,8 +323,6 @@ Shadow DOM provides an encapsulation for components, so as a general rule it doe
``` ```
@Component({ @Component({
selector: '[kid]' selector: '[kid]'
})
@View({
templateUrl: 'kid.html', templateUrl: 'kid.html',
directives: [] directives: []
}) })
@ -347,8 +339,6 @@ class Kid {
@Component({ @Component({
selector: '[dad]' selector: '[dad]'
})
@View({
templateUrl: 'dad.html', templateUrl: 'dad.html',
directives: [Kid] directives: [Kid]
}) })
@ -361,9 +351,7 @@ class Dad {
@Component({ @Component({
selector: '[grandpa]', selector: '[grandpa]',
viewBindings: [] viewBindings: [],
})
@View({
templateUrl: 'grandpa.html', templateUrl: 'grandpa.html',
directives: [Dad] directives: [Dad]
}) })

View File

@ -179,9 +179,7 @@ Both `MyComponent` and `MyDirective` are created on the same element.
], ],
viewBindings: [ viewBindings: [
bind('viewService').toValue('View_MyComponentService') bind('viewService').toValue('View_MyComponentService')
] ],
})
@View({
template: `<needs-view-service></needs-view-service>`, template: `<needs-view-service></needs-view-service>`,
directives: [NeedsViewService] directives: [NeedsViewService]
}) })

View File

@ -9,7 +9,7 @@ import {CORE_DIRECTIVES} from './directives';
* NgModel). * NgModel).
* *
* This collection can be used to quickly enumerate all the built-in directives in the `directives` * This collection can be used to quickly enumerate all the built-in directives in the `directives`
* property of the `@Component` or `@View` decorators. * property of the `@Component` decorator.
* *
* ### Example * ### Example
* *

View File

@ -11,7 +11,7 @@ import {NgPlural, NgPluralCase} from './ng_plural';
* application. * application.
* *
* This collection can be used to quickly enumerate all the built-in directives in the `directives` * This collection can be used to quickly enumerate all the built-in directives in the `directives`
* property of the `@View` annotation. * property of the `@Component` annotation.
* *
* ### Example ([live demo](http://plnkr.co/edit/yakGwpCdUkg0qfzX5m8g?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/yakGwpCdUkg0qfzX5m8g?p=preview))
* *

View File

@ -32,8 +32,8 @@ export class SwitchView {
* ### Example ([live demo](http://plnkr.co/edit/DQMTII95CbuqWrl3lYAs?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/DQMTII95CbuqWrl3lYAs?p=preview))
* *
* ```typescript * ```typescript
* @Component({selector: 'app'}) * @Component({
* @View({ * selector: 'app',
* template: ` * template: `
* <p>Value = {{value}}</p> * <p>Value = {{value}}</p>
* <button (click)="inc()">Increment</button> * <button (click)="inc()">Increment</button>

View File

@ -50,7 +50,7 @@ export {ControlValueAccessor} from './directives/control_value_accessor';
/** /**
* *
* A list of all the form directives used as part of a `@View` annotation. * A list of all the form directives used as part of a `@Component` annotation.
* *
* This is a shorthand for importing them each individually. * This is a shorthand for importing them each individually.
* *

View File

@ -33,8 +33,6 @@ const controlGroupProvider =
* @Component({ * @Component({
* selector: 'my-app', * selector: 'my-app',
* directives: [FORM_DIRECTIVES], * directives: [FORM_DIRECTIVES],
* })
* @View({
* template: ` * template: `
* <div> * <div>
* <h2>Angular2 Control &amp; ControlGroup Example</h2> * <h2>Angular2 Control &amp; ControlGroup Example</h2>

View File

@ -20,7 +20,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
* application. * application.
* *
* This collection can be used to quickly enumerate all the built-in pipes in the `pipes` * This collection can be used to quickly enumerate all the built-in pipes in the `pipes`
* property of the `@Component` or `@View` decorators. * property of the `@Component` decorator.
*/ */
export const COMMON_PIPES = CONST_EXPR([ export const COMMON_PIPES = CONST_EXPR([
AsyncPipe, AsyncPipe,

View File

@ -45,7 +45,7 @@ export class ViewResolver {
if (isPresent(compMeta)) { if (isPresent(compMeta)) {
if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl) && isBlank(viewMeta)) { if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl) && isBlank(viewMeta)) {
throw new BaseException( throw new BaseException(
`Component '${stringify(component)}' must have either 'template', 'templateUrl', or '@View' set.`); `Component '${stringify(component)}' must have either 'template' or 'templateUrl' set.`);
} else if (isPresent(compMeta.template) && isPresent(viewMeta)) { } else if (isPresent(compMeta.template) && isPresent(viewMeta)) {
this._throwMixingViewAndComponent("template", component); this._throwMixingViewAndComponent("template", component);
@ -84,7 +84,8 @@ export class ViewResolver {
} }
} else { } else {
if (isBlank(viewMeta)) { if (isBlank(viewMeta)) {
throw new BaseException(`No View decorator found on component '${stringify(component)}'`); throw new BaseException(
`Could not compile '${stringify(component)}' because it is not a component.`);
} else { } else {
return viewMeta; return viewMeta;
} }

View File

@ -254,7 +254,6 @@ export interface ComponentFactory {
* import {Component, View} from "angular2/core"; * import {Component, View} from "angular2/core";
* *
* @Component({...}) * @Component({...})
* @View({...})
* class MyComponent { * class MyComponent {
* constructor() { * constructor() {
* ... * ...
@ -481,8 +480,7 @@ export interface HostListenerFactory {
/** /**
* Declare reusable UI building blocks for an application. * Declare reusable UI building blocks for an application.
* *
* Each Angular component requires a single `@Component` and at least one `@View` annotation. The * Each Angular component requires a single `@Component` annotation. The `@Component`
* `@Component`
* annotation specifies when a component is instantiated, and which properties and hostListeners it * annotation specifies when a component is instantiated, and which properties and hostListeners it
* binds to. * binds to.
* *
@ -493,8 +491,6 @@ export interface HostListenerFactory {
* *
* All template expressions and statements are then evaluated against the component instance. * All template expressions and statements are then evaluated against the component instance.
* *
* For details on the `@View` annotation, see {@link ViewMetadata}.
*
* ## Lifecycle hooks * ## Lifecycle hooks
* *
* When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are * When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are
@ -918,8 +914,7 @@ export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(Directi
* } * }
* ``` * ```
*/ */
export var View: ViewFactory = var View: ViewFactory = <ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
<ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
/** /**
* Specifies that a constant attribute value should be injected. * Specifies that a constant attribute value should be injected.
@ -1154,8 +1149,8 @@ export var ViewChild: ViewChildFactory = makePropDecorator(ViewChildMetadata);
* ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
* *
* ```javascript * ```javascript
* @Component({...}) * @Component({
* @View({ * ...,
* template: ` * template: `
* <item> a </item> * <item> a </item>
* <item> b </item> * <item> b </item>

View File

@ -242,8 +242,8 @@ export class ContentChildMetadata extends QueryMetadata {
* ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
* *
* ```javascript * ```javascript
* @Component({...}) * @Component({
* @View({ * ...,
* template: ` * template: `
* <item> a </item> * <item> a </item>
* <item> b </item> * <item> b </item>

View File

@ -59,8 +59,10 @@ export class RouteParams {
* ]) * ])
* class AppCmp {} * class AppCmp {}
* *
* @Component({...}) * @Component({
* @View({ template: 'user: {{isAdmin}}' }) * ...,
* template: 'user: {{isAdmin}}'
* })
* class UserCmp { * class UserCmp {
* string: isAdmin; * string: isAdmin;
* constructor(data: RouteData) { * constructor(data: RouteData) {

View File

@ -15,7 +15,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {ListWrapper, StringMapWrapper, SetWrapper} from 'angular2/src/facade/collection'; import {ListWrapper, StringMapWrapper, SetWrapper} from 'angular2/src/facade/collection';
import {Component, View, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {NgClass} from 'angular2/src/common/directives/ng_class'; import {NgClass} from 'angular2/src/common/directives/ng_class';
@ -528,8 +528,7 @@ export function main() {
}) })
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''})
@View({directives: [NgClass, NgFor]})
class TestComponent { class TestComponent {
condition: boolean = true; condition: boolean = true;
items: any[]; items: any[];

View File

@ -14,7 +14,7 @@ import {
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
import {Component, View, TemplateRef, ContentChild} from 'angular2/core'; import {Component, TemplateRef, ContentChild} from 'angular2/core';
import {NgFor} from 'angular2/src/common/directives/ng_for'; import {NgFor} from 'angular2/src/common/directives/ng_for';
import {NgIf} from 'angular2/src/common/directives/ng_if'; import {NgIf} from 'angular2/src/common/directives/ng_if';
import {By} from 'angular2/platform/common_dom'; import {By} from 'angular2/platform/common_dom';
@ -472,8 +472,7 @@ class Foo {
toString() { return 'foo'; } toString() { return 'foo'; }
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [NgFor, NgIf], template: ''})
@View({directives: [NgFor, NgIf]})
class TestComponent { class TestComponent {
@ContentChild(TemplateRef) contentTpl: TemplateRef; @ContentChild(TemplateRef) contentTpl: TemplateRef;
items: any; items: any;
@ -482,8 +481,7 @@ class TestComponent {
trackByIndex(index: number, item: any): number { return index; } trackByIndex(index: number, item: any): number { return index; }
} }
@Component({selector: 'outer-cmp'}) @Component({selector: 'outer-cmp', directives: [TestComponent], template: ''})
@View({directives: [TestComponent]})
class ComponentUsingTestComponent { class ComponentUsingTestComponent {
items: any; items: any;
constructor() { this.items = [1, 2]; } constructor() { this.items = [1, 2]; }

View File

@ -14,7 +14,7 @@ import {
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {IS_DART} from 'angular2/src/facade/lang'; import {IS_DART} from 'angular2/src/facade/lang';
@ -224,8 +224,7 @@ export function main() {
}); });
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [NgIf], template: ''})
@View({directives: [NgIf]})
class TestComponent { class TestComponent {
booleanCondition: boolean; booleanCondition: boolean;
nestedBooleanCondition: boolean; nestedBooleanCondition: boolean;

View File

@ -13,7 +13,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View, Injectable, provide} from 'angular2/core'; import {Component, Injectable, provide} from 'angular2/core';
import {NgPlural, NgPluralCase, NgLocalization} from 'angular2/common'; import {NgPlural, NgPluralCase, NgLocalization} from 'angular2/common';
export function main() { export function main() {
@ -128,8 +128,7 @@ export class TestLocalizationMap extends NgLocalization {
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [NgPlural, NgPluralCase], template: ''})
@View({directives: [NgPlural, NgPluralCase]})
class TestComponent { class TestComponent {
switchValue: number; switchValue: number;

View File

@ -16,7 +16,7 @@ import {
import {StringMapWrapper} from 'angular2/src/facade/collection'; import {StringMapWrapper} from 'angular2/src/facade/collection';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {NgStyle} from 'angular2/src/common/directives/ng_style'; import {NgStyle} from 'angular2/src/common/directives/ng_style';
@ -137,8 +137,7 @@ export function main() {
}) })
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [NgStyle], template: ''})
@View({directives: [NgStyle]})
class TestComponent { class TestComponent {
expr; expr;
} }

View File

@ -12,7 +12,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/src/common/directives/ng_switch'; import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/src/common/directives/ng_switch';
@ -145,8 +145,8 @@ export function main() {
}); });
} }
@Component({selector: 'test-cmp'}) @Component(
@View({directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault]}) {selector: 'test-cmp', directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault], template: ''})
class TestComponent { class TestComponent {
switchValue: any; switchValue: any;
when1: any; when1: any;

View File

@ -12,7 +12,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Component, Directive, View} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
import {ElementRef} from 'angular2/src/core/linker/element_ref'; import {ElementRef} from 'angular2/src/core/linker/element_ref';
export function main() { export function main() {
@ -65,8 +65,7 @@ class TestDirective {
constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); } constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); }
} }
@Component({selector: 'test-cmp'}) @Component({selector: 'test-cmp', directives: [TestDirective], template: ''})
@View({directives: [TestDirective]})
class TestComponent { class TestComponent {
text: string; text: string;
constructor() { this.text = 'foo'; } constructor() { this.text = 'foo'; }

View File

@ -1,4 +1,4 @@
import {Component, Directive, View, Output, EventEmitter} from 'angular2/core'; import {Component, Directive, Output, EventEmitter} from 'angular2/core';
import { import {
ComponentFixture, ComponentFixture,
afterEach, afterEach,

View File

@ -13,7 +13,7 @@ import {
beforeEachProviders beforeEachProviders
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';
import {SpyTemplateCompiler} from './spies'; import {SpyTemplateCompiler} from './spies';
import {TemplateCompiler} from 'angular2/src/compiler/compiler'; import {TemplateCompiler} from 'angular2/src/compiler/compiler';
@ -52,7 +52,6 @@ export function main() {
}); });
} }
@Component({selector: 'some-comp'}) @Component({selector: 'some-comp', template: ''})
@View({template: ''})
class SomeComponent { class SomeComponent {
} }

View File

@ -18,7 +18,6 @@ import {RuntimeMetadataResolver} from 'angular2/src/compiler/runtime_metadata';
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces'; import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces';
import { import {
Component, Component,
View,
Directive, Directive,
ViewEncapsulation, ViewEncapsulation,
ChangeDetectionStrategy, ChangeDetectionStrategy,
@ -125,9 +124,7 @@ class ComponentWithoutModuleId {
}, },
exportAs: 'someExportAs', exportAs: 'someExportAs',
moduleId: 'someModuleId', moduleId: 'someModuleId',
changeDetection: ChangeDetectionStrategy.CheckAlways changeDetection: ChangeDetectionStrategy.CheckAlways,
})
@View({
template: 'someTemplate', template: 'someTemplate',
templateUrl: 'someTemplateUrl', templateUrl: 'someTemplateUrl',
encapsulation: ViewEncapsulation.Emulated, encapsulation: ViewEncapsulation.Emulated,

View File

@ -37,7 +37,7 @@ import {AppView, AppProtoView} from 'angular2/src/core/linker/view';
import {AppElement} from 'angular2/src/core/linker/element'; import {AppElement} from 'angular2/src/core/linker/element';
import {Locals, ChangeDetectorGenConfig} from 'angular2/src/core/change_detection/change_detection'; import {Locals, ChangeDetectorGenConfig} from 'angular2/src/core/change_detection/change_detection';
import {Component, View, Directive, provide, RenderComponentType} from 'angular2/core'; import {Component, Directive, provide, RenderComponentType} from 'angular2/core';
import {TEST_PROVIDERS} from './test_bindings'; import {TEST_PROVIDERS} from './test_bindings';
import { import {
@ -338,9 +338,7 @@ export class UpperCasePipe implements PipeTransform {
selector: 'comp-a', selector: 'comp-a',
host: {'[title]': '\'someHostValue\''}, host: {'[title]': '\'someHostValue\''},
moduleId: THIS_MODULE_ID, moduleId: THIS_MODULE_ID,
exportAs: 'someExportAs' exportAs: 'someExportAs',
})
@View({
template: '<a [href]="\'someCtxValue\' | uppercase"></a>', template: '<a [href]="\'someCtxValue\' | uppercase"></a>',
styles: ['div {color: red}'], styles: ['div {color: red}'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
@ -349,8 +347,9 @@ export class UpperCasePipe implements PipeTransform {
export class CompWithBindingsAndStylesAndPipes { export class CompWithBindingsAndStylesAndPipes {
} }
@Component({selector: 'tree', moduleId: THIS_MODULE_ID}) @Component({
@View({ selector: 'tree',
moduleId: THIS_MODULE_ID,
template: '<template><tree></tree></template>', template: '<template><tree></tree></template>',
directives: [TreeComp], directives: [TreeComp],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
@ -358,8 +357,9 @@ export class CompWithBindingsAndStylesAndPipes {
export class TreeComp { export class TreeComp {
} }
@Component({selector: 'comp-wit-dup-tpl', moduleId: THIS_MODULE_ID}) @Component({
@View({ selector: 'comp-wit-dup-tpl',
moduleId: THIS_MODULE_ID,
template: '<tree></tree>', template: '<tree></tree>',
directives: [TreeComp, TreeComp], directives: [TreeComp, TreeComp],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
@ -367,13 +367,18 @@ export class TreeComp {
export class CompWithDupDirectives { export class CompWithDupDirectives {
} }
@Component({selector: 'comp-url', moduleId: THIS_MODULE_ID}) @Component({
@View({templateUrl: 'compUrl.html', encapsulation: ViewEncapsulation.None}) selector: 'comp-url',
moduleId: THIS_MODULE_ID,
templateUrl: 'compUrl.html',
encapsulation: ViewEncapsulation.None
})
export class CompWithTemplateUrl { export class CompWithTemplateUrl {
} }
@Component({selector: 'comp-tpl', moduleId: THIS_MODULE_ID}) @Component({
@View({ selector: 'comp-tpl',
moduleId: THIS_MODULE_ID,
template: '<template><a [href]="\'someEmbeddedValue\'"></a></template>', template: '<template><a [href]="\'someEmbeddedValue\'"></a></template>',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@ -382,18 +387,22 @@ export class CompWithEmbeddedTemplate {
@Directive({selector: 'plain'}) @Directive({selector: 'plain'})
@View({template: ''})
export class NonComponent { export class NonComponent {
} }
@Component({selector: 'comp2', moduleId: THIS_MODULE_ID}) @Component({
@View({template: '<b></b>', encapsulation: ViewEncapsulation.None}) selector: 'comp2',
moduleId: THIS_MODULE_ID,
template: '<b></b>',
encapsulation: ViewEncapsulation.None
})
export class Comp2 { export class Comp2 {
} }
@Component({selector: 'comp1', moduleId: THIS_MODULE_ID}) @Component({
@View({ selector: 'comp1',
moduleId: THIS_MODULE_ID,
template: '<a></a>, <comp2></comp2>', template: '<a></a>, <comp2></comp2>',
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
directives: [Comp2] directives: [Comp2]
@ -401,8 +410,9 @@ export class Comp2 {
export class Comp1 { export class Comp1 {
} }
@Component({selector: 'comp-with-2nested', moduleId: THIS_MODULE_ID}) @Component({
@View({ selector: 'comp-with-2nested',
moduleId: THIS_MODULE_ID,
template: '<comp1></comp1>, <comp2></comp2>', template: '<comp1></comp1>, <comp2></comp2>',
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
directives: [Comp1, Comp2] directives: [Comp1, Comp2]

View File

@ -22,7 +22,7 @@ import {Injectable} from 'angular2/core';
import {NgFor, NgIf} from 'angular2/common'; import {NgFor, NgIf} from 'angular2/common';
import {By} from 'angular2/platform/common_dom'; import {By} from 'angular2/platform/common_dom';
import {Directive, Component, View, Input} from 'angular2/src/core/metadata'; import {Directive, Component, Input} from 'angular2/src/core/metadata';
@Injectable() @Injectable()
class Logger { class Logger {
@ -43,8 +43,8 @@ class MessageDir {
set message(newMessage) { this.logger.add(newMessage); } set message(newMessage) { this.logger.add(newMessage); }
} }
@Component({selector: 'child-comp'}) @Component({
@View({ selector: 'child-comp',
template: `<div class="child" message="child"> template: `<div class="child" message="child">
<span class="childnested" message="nestedchild">Child</span> <span class="childnested" message="nestedchild">Child</span>
</div> </div>
@ -58,8 +58,9 @@ class ChildComp {
constructor() { this.childBinding = 'Original'; } constructor() { this.childBinding = 'Original'; }
} }
@Component({selector: 'parent-comp', viewProviders: [Logger]}) @Component({
@View({ selector: 'parent-comp',
viewProviders: [Logger],
template: `<div class="parent" message="parent"> template: `<div class="parent" message="parent">
<span class="parentnested" message="nestedparent">Parent</span> <span class="parentnested" message="nestedparent">Parent</span>
</div> </div>
@ -81,8 +82,8 @@ class CustomEmitter {
constructor() { this.myevent = new EventEmitter(); } constructor() { this.myevent = new EventEmitter(); }
} }
@Component({selector: 'events-comp'}) @Component({
@View({ selector: 'events-comp',
template: `<button (click)="handleClick()"></button> template: `<button (click)="handleClick()"></button>
<custom-emitter (myevent)="handleCustom()"></custom-emitter>`, <custom-emitter (myevent)="handleCustom()"></custom-emitter>`,
directives: [CustomEmitter], directives: [CustomEmitter],
@ -102,8 +103,9 @@ class EventsComp {
handleCustom() { this.customed = true; } handleCustom() { this.customed = true; }
} }
@Component({selector: 'cond-content-comp', viewProviders: [Logger]}) @Component({
@View({ selector: 'cond-content-comp',
viewProviders: [Logger],
template: `<div class="child" message="child" *ngIf="myBool"><ng-content></ng-content></div>`, template: `<div class="child" message="child" *ngIf="myBool"><ng-content></ng-content></div>`,
directives: [NgIf, MessageDir], directives: [NgIf, MessageDir],
}) })
@ -112,8 +114,9 @@ class ConditionalContentComp {
myBool: boolean = false; myBool: boolean = false;
} }
@Component({selector: 'conditional-parent-comp', viewProviders: [Logger]}) @Component({
@View({ selector: 'conditional-parent-comp',
viewProviders: [Logger],
template: `<span class="parent" [innerHtml]="parentBinding"></span> template: `<span class="parent" [innerHtml]="parentBinding"></span>
<cond-content-comp class="cond-content-comp-class"> <cond-content-comp class="cond-content-comp-class">
<span class="from-parent"></span> <span class="from-parent"></span>
@ -126,8 +129,9 @@ class ConditionalParentComp {
constructor() { this.parentBinding = 'OriginalParent'; } constructor() { this.parentBinding = 'OriginalParent'; }
} }
@Component({selector: 'using-for', viewProviders: [Logger]}) @Component({
@View({ selector: 'using-for',
viewProviders: [Logger],
template: `<span *ngFor="#thing of stuff" [innerHtml]="thing"></span> template: `<span *ngFor="#thing of stuff" [innerHtml]="thing"></span>
<ul message="list"> <ul message="list">
<li *ngFor="#item of stuff" [innerHtml]="item"></li> <li *ngFor="#item of stuff" [innerHtml]="item"></li>

View File

@ -22,7 +22,7 @@ import {
AfterViewInit, AfterViewInit,
AfterViewChecked AfterViewChecked
} from 'angular2/core'; } from 'angular2/core';
import {Directive, Component, View, ViewMetadata} from 'angular2/src/core/metadata'; import {Directive, Component, ViewMetadata} from 'angular2/src/core/metadata';
export function main() { export function main() {
describe('directive lifecycle integration spec', () => { describe('directive lifecycle integration spec', () => {
@ -63,10 +63,14 @@ class LifecycleDir implements DoCheck {
ngDoCheck() { this._log.add("child_ngDoCheck"); } ngDoCheck() { this._log.add("child_ngDoCheck"); }
} }
@Component({selector: "[lifecycle]", inputs: ['field']}) @Component({
@View({template: `<div lifecycle-dir></div>`, directives: [LifecycleDir]}) selector: "[lifecycle]",
class LifecycleCmp implements OnChanges, OnInit, DoCheck, AfterContentInit, AfterContentChecked, inputs: ['field'],
AfterViewInit, AfterViewChecked { template: `<div lifecycle-dir></div>`,
directives: [LifecycleDir]
})
class LifecycleCmp implements OnChanges,
OnInit, DoCheck, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked {
field; field;
constructor(private _log: Log) {} constructor(private _log: Log) {}
@ -85,7 +89,6 @@ class LifecycleCmp implements OnChanges, OnInit, DoCheck, AfterContentInit, Afte
ngAfterViewChecked() { this._log.add("ngAfterViewChecked"); } ngAfterViewChecked() { this._log.add("ngAfterViewChecked"); }
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp', directives: []})
@View({directives: []})
class MyComp { class MyComp {
} }

View File

@ -19,8 +19,7 @@ import {
Directive, Directive,
Inject, Inject,
Query, Query,
QueryList, QueryList
View
} from 'angular2/core'; } from 'angular2/core';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {Type} from 'angular2/src/facade/lang'; import {Type} from 'angular2/src/facade/lang';
@ -39,16 +38,17 @@ export function main() {
}); });
} }
@Component({selector: 'app', viewProviders: [forwardRef(() => Frame)]}) @Component({
@View({ selector: 'app',
viewProviders: [forwardRef(() => Frame)],
template: `<door><lock></lock></door>`, template: `<door><lock></lock></door>`,
directives: [forwardRef(() => Door), forwardRef(() => Lock)], directives: [forwardRef(() => Door), forwardRef(() => Lock)],
}) })
class App { class App {
} }
@Component({selector: 'lock'}) @Component({
@View({ selector: 'lock',
directives: [NgFor], directives: [NgFor],
template: `{{frame.name}}(<span *ngFor="var lock of locks">{{lock.name}}</span>)`, template: `{{frame.name}}(<span *ngFor="var lock of locks">{{lock.name}}</span>)`,
}) })

View File

@ -19,7 +19,7 @@ import {
import {OnDestroy} from 'angular2/core'; import {OnDestroy} from 'angular2/core';
import {Injector} from 'angular2/core'; import {Injector} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {Component, View, ViewMetadata} from 'angular2/src/core/metadata'; import {Component, ViewMetadata} from 'angular2/src/core/metadata';
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
import {ElementRef, ElementRef_} from 'angular2/src/core/linker/element_ref'; import {ElementRef, ElementRef_} from 'angular2/src/core/linker/element_ref';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens'; import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
@ -369,10 +369,7 @@ function createRootElement(doc: any, name: string): any {
return rootEl; return rootEl;
} }
@Component({ @Component({selector: 'child-cmp', template: '{{ctxProp}}'})
selector: 'child-cmp',
})
@View({template: '{{ctxProp}}'})
class ChildComp { class ChildComp {
ctxProp: string; ctxProp: string;
constructor() { this.ctxProp = 'hello'; } constructor() { this.ctxProp = 'hello'; }
@ -381,8 +378,11 @@ class ChildComp {
class DynamicallyCreatedComponentService {} class DynamicallyCreatedComponentService {}
@Component({selector: 'hello-cmp', viewProviders: [DynamicallyCreatedComponentService]}) @Component({
@View({template: "{{greeting}}"}) selector: 'hello-cmp',
viewProviders: [DynamicallyCreatedComponentService],
template: "{{greeting}}"
})
class DynamicallyCreatedCmp implements OnDestroy { class DynamicallyCreatedCmp implements OnDestroy {
greeting: string; greeting: string;
dynamicallyCreatedComponentService: DynamicallyCreatedComponentService; dynamicallyCreatedComponentService: DynamicallyCreatedComponentService;
@ -396,48 +396,41 @@ class DynamicallyCreatedCmp implements OnDestroy {
ngOnDestroy() { this.destroyed = true; } ngOnDestroy() { this.destroyed = true; }
} }
@Component({selector: 'dummy'}) @Component({selector: 'dummy', template: "DynamicallyLoaded;"})
@View({template: "DynamicallyLoaded;"})
class DynamicallyLoaded { class DynamicallyLoaded {
} }
@Component({selector: 'dummy'}) @Component({selector: 'dummy', template: "DynamicallyLoaded;"})
@View({template: "DynamicallyLoaded;"})
class DynamicallyLoadedThrows { class DynamicallyLoadedThrows {
constructor() { throw new BaseException("ThrownInConstructor"); } constructor() { throw new BaseException("ThrownInConstructor"); }
} }
@Component({selector: 'dummy'}) @Component({selector: 'dummy', template: "DynamicallyLoaded2;"})
@View({template: "DynamicallyLoaded2;"})
class DynamicallyLoaded2 { class DynamicallyLoaded2 {
} }
@Component({selector: 'dummy', host: {'[id]': 'id'}}) @Component({selector: 'dummy', host: {'[id]': 'id'}, template: "DynamicallyLoadedWithHostProps;"})
@View({template: "DynamicallyLoadedWithHostProps;"})
class DynamicallyLoadedWithHostProps { class DynamicallyLoadedWithHostProps {
id: string; id: string;
constructor() { this.id = "default"; } constructor() { this.id = "default"; }
} }
@Component({selector: 'dummy'}) @Component({selector: 'dummy', template: "dynamic(<ng-content></ng-content>)"})
@View({template: "dynamic(<ng-content></ng-content>)"})
class DynamicallyLoadedWithNgContent { class DynamicallyLoadedWithNgContent {
id: string; id: string;
constructor() { this.id = "default"; } constructor() { this.id = "default"; }
} }
@Component({selector: 'location'}) @Component({selector: 'location', template: "Location;"})
@View({template: "Location;"})
class Location { class Location {
elementRef: ElementRef; elementRef: ElementRef;
constructor(elementRef: ElementRef) { this.elementRef = elementRef; } constructor(elementRef: ElementRef) { this.elementRef = elementRef; }
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp', directives: []})
@View({directives: []})
class MyComp { class MyComp {
ctxBoolProp: boolean; ctxBoolProp: boolean;

View File

@ -71,7 +71,6 @@ import {
import { import {
Directive, Directive,
Component, Component,
View,
ViewMetadata, ViewMetadata,
Attribute, Attribute,
Query, Query,
@ -1358,8 +1357,7 @@ function declareTests() {
try { try {
tcb.createAsync(ComponentWithoutView); tcb.createAsync(ComponentWithoutView);
} catch (e) { } catch (e) {
expect(e.message) expect(e.message).toContain(`must have either 'template' or 'templateUrl' set.`);
.toContain(`must have either 'template', 'templateUrl', or '@View' set.`);
return null; return null;
} }
})); }));
@ -1936,8 +1934,7 @@ class MyService {
constructor() { this.greeting = 'hello'; } constructor() { this.greeting = 'hello'; }
} }
@Component({selector: 'simple-imp-cmp'}) @Component({selector: 'simple-imp-cmp', template: ''})
@View({template: ''})
@Injectable() @Injectable()
class SimpleImperativeViewComponent { class SimpleImperativeViewComponent {
done; done;
@ -1979,9 +1976,12 @@ class DirectiveWithTitleAndHostProperty {
title: string; title: string;
} }
@Component( @Component({
{selector: 'push-cmp', inputs: ['prop'], changeDetection: ChangeDetectionStrategy.OnPush}) selector: 'push-cmp',
@View({template: '{{field}}'}) inputs: ['prop'],
changeDetection: ChangeDetectionStrategy.OnPush,
template: '{{field}}'
})
@Injectable() @Injectable()
class PushCmp { class PushCmp {
numberOfChecks: number; numberOfChecks: number;
@ -1998,9 +1998,9 @@ class PushCmp {
@Component({ @Component({
selector: 'push-cmp-with-ref', selector: 'push-cmp-with-ref',
inputs: ['prop'], inputs: ['prop'],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush,
template: '{{field}}'
}) })
@View({template: '{{field}}'})
@Injectable() @Injectable()
class PushCmpWithRef { class PushCmpWithRef {
numberOfChecks: number; numberOfChecks: number;
@ -2055,8 +2055,7 @@ class PushCmpWithAsyncPipe {
resolve(value) { this.completer.resolve(value); } resolve(value) { this.completer.resolve(value); }
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp', directives: []})
@View({directives: []})
@Injectable() @Injectable()
class MyComp { class MyComp {
ctxProp: string; ctxProp: string;
@ -2071,8 +2070,13 @@ class MyComp {
throwError() { throw 'boom'; } throwError() { throw 'boom'; }
} }
@Component({selector: 'child-cmp', inputs: ['dirProp'], viewProviders: [MyService]}) @Component({
@View({directives: [MyDir], template: '{{ctxProp}}'}) selector: 'child-cmp',
inputs: ['dirProp'],
viewProviders: [MyService],
directives: [MyDir],
template: '{{ctxProp}}'
})
@Injectable() @Injectable()
class ChildComp { class ChildComp {
ctxProp: string; ctxProp: string;
@ -2083,15 +2087,13 @@ class ChildComp {
} }
} }
@Component({selector: 'child-cmp-no-template'}) @Component({selector: 'child-cmp-no-template', directives: [], template: ''})
@View({directives: [], template: ''})
@Injectable() @Injectable()
class ChildCompNoTemplate { class ChildCompNoTemplate {
ctxProp: string = 'hello'; ctxProp: string = 'hello';
} }
@Component({selector: 'child-cmp-svc'}) @Component({selector: 'child-cmp-svc', template: '{{ctxProp}}'})
@View({template: '{{ctxProp}}'})
@Injectable() @Injectable()
class ChildCompUsingService { class ChildCompUsingService {
ctxProp: string; ctxProp: string;
@ -2105,8 +2107,11 @@ class SomeDirective {
class SomeDirectiveMissingAnnotation {} class SomeDirectiveMissingAnnotation {}
@Component({selector: 'cmp-with-host'}) @Component({
@View({template: '<p>Component with an injected host</p>', directives: [SomeDirective]}) selector: 'cmp-with-host',
template: '<p>Component with an injected host</p>',
directives: [SomeDirective]
})
@Injectable() @Injectable()
class CompWithHost { class CompWithHost {
myHost: SomeDirective; myHost: SomeDirective;
@ -2283,8 +2288,8 @@ class ToolbarViewContainer {
} }
} }
@Component({selector: 'toolbar'}) @Component({
@View({ selector: 'toolbar',
template: 'TOOLBAR(<div *ngFor="var part of query" [toolbarVc]="part"></div>)', template: 'TOOLBAR(<div *ngFor="var part of query" [toolbarVc]="part"></div>)',
directives: [ToolbarViewContainer, NgFor] directives: [ToolbarViewContainer, NgFor]
}) })
@ -2321,9 +2326,9 @@ function createInjectableWithLogging(inj: Injector) {
selector: 'component-providing-logging-injectable', selector: 'component-providing-logging-injectable',
providers: [ providers: [
new Provider(InjectableService, {useFactory: createInjectableWithLogging, deps: [Injector]}) new Provider(InjectableService, {useFactory: createInjectableWithLogging, deps: [Injector]})
] ],
template: ''
}) })
@View({template: ''})
@Injectable() @Injectable()
class ComponentProvidingLoggingInjectable { class ComponentProvidingLoggingInjectable {
created: boolean = false; created: boolean = false;
@ -2335,8 +2340,11 @@ class ComponentProvidingLoggingInjectable {
class DirectiveProvidingInjectable { class DirectiveProvidingInjectable {
} }
@Component({selector: 'directive-providing-injectable', viewProviders: [[InjectableService]]}) @Component({
@View({template: ''}) selector: 'directive-providing-injectable',
viewProviders: [[InjectableService]],
template: ''
})
@Injectable() @Injectable()
class DirectiveProvidingInjectableInView { class DirectiveProvidingInjectableInView {
} }
@ -2344,16 +2352,15 @@ class DirectiveProvidingInjectableInView {
@Component({ @Component({
selector: 'directive-providing-injectable', selector: 'directive-providing-injectable',
providers: [new Provider(InjectableService, {useValue: 'host'})], providers: [new Provider(InjectableService, {useValue: 'host'})],
viewProviders: [new Provider(InjectableService, {useValue: 'view'})] viewProviders: [new Provider(InjectableService, {useValue: 'view'})],
template: ''
}) })
@View({template: ''})
@Injectable() @Injectable()
class DirectiveProvidingInjectableInHostAndView { class DirectiveProvidingInjectableInHostAndView {
} }
@Component({selector: 'directive-consuming-injectable'}) @Component({selector: 'directive-consuming-injectable', template: ''})
@View({template: ''})
@Injectable() @Injectable()
class DirectiveConsumingInjectable { class DirectiveConsumingInjectable {
injectable; injectable;
@ -2369,8 +2376,7 @@ class DirectiveContainingDirectiveConsumingAnInjectable {
directive; directive;
} }
@Component({selector: 'directive-consuming-injectable-unbounded'}) @Component({selector: 'directive-consuming-injectable-unbounded', template: ''})
@View({template: ''})
@Injectable() @Injectable()
class DirectiveConsumingInjectableUnbounded { class DirectiveConsumingInjectableUnbounded {
injectable; injectable;
@ -2413,9 +2419,7 @@ function createParentBus(peb) {
providers: [ providers: [
new Provider(EventBus, new Provider(EventBus,
{useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]}) {useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]})
] ],
})
@View({
directives: [forwardRef(() => ChildConsumingEventBus)], directives: [forwardRef(() => ChildConsumingEventBus)],
template: ` template: `
<child-consuming-event-bus></child-consuming-event-bus> <child-consuming-event-bus></child-consuming-event-bus>

View File

@ -30,7 +30,6 @@ import {
Directive, Directive,
ElementRef, ElementRef,
TemplateRef, TemplateRef,
View,
ViewContainerRef, ViewContainerRef,
ViewEncapsulation, ViewEncapsulation,
ViewMetadata ViewMetadata
@ -580,26 +579,28 @@ export function main() {
}); });
} }
@Component({selector: 'main'}) @Component({selector: 'main', template: '', directives: []})
@View({template: '', directives: []})
class MainComp { class MainComp {
text: string = ''; text: string = '';
} }
@Component({selector: 'other'}) @Component({selector: 'other', template: '', directives: []})
@View({template: '', directives: []})
class OtherComp { class OtherComp {
text: string = ''; text: string = '';
} }
@Component({selector: 'simple', inputs: ['stringProp']}) @Component({
@View({template: 'SIMPLE(<ng-content></ng-content>)', directives: []}) selector: 'simple',
inputs: ['stringProp'],
template: 'SIMPLE(<ng-content></ng-content>)',
directives: []
})
class Simple { class Simple {
stringProp: string = ''; stringProp: string = '';
} }
@Component({selector: 'simple-native1'}) @Component({
@View({ selector: 'simple-native1',
template: 'SIMPLE1(<content></content>)', template: 'SIMPLE1(<content></content>)',
directives: [], directives: [],
encapsulation: ViewEncapsulation.Native, encapsulation: ViewEncapsulation.Native,
@ -608,8 +609,8 @@ class Simple {
class SimpleNative1 { class SimpleNative1 {
} }
@Component({selector: 'simple-native2'}) @Component({
@View({ selector: 'simple-native2',
template: 'SIMPLE2(<content></content>)', template: 'SIMPLE2(<content></content>)',
directives: [], directives: [],
encapsulation: ViewEncapsulation.Native, encapsulation: ViewEncapsulation.Native,
@ -618,13 +619,12 @@ class SimpleNative1 {
class SimpleNative2 { class SimpleNative2 {
} }
@Component({selector: 'empty'}) @Component({selector: 'empty', template: '', directives: []})
@View({template: '', directives: []})
class Empty { class Empty {
} }
@Component({selector: 'multiple-content-tags'}) @Component({
@View({ selector: 'multiple-content-tags',
template: '(<ng-content SELECT=".left"></ng-content>, <ng-content></ng-content>)', template: '(<ng-content SELECT=".left"></ng-content>, <ng-content></ng-content>)',
directives: [] directives: []
}) })
@ -645,16 +645,16 @@ class ProjectDirective {
hide() { this.vc.clear(); } hide() { this.vc.clear(); }
} }
@Component({selector: 'outer-with-indirect-nested'}) @Component({
@View({ selector: 'outer-with-indirect-nested',
template: 'OUTER(<simple><div><ng-content></ng-content></div></simple>)', template: 'OUTER(<simple><div><ng-content></ng-content></div></simple>)',
directives: [Simple] directives: [Simple]
}) })
class OuterWithIndirectNestedComponent { class OuterWithIndirectNestedComponent {
} }
@Component({selector: 'outer'}) @Component({
@View({ selector: 'outer',
template: template:
'OUTER(<inner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></inner>)', 'OUTER(<inner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></inner>)',
directives: [forwardRef(() => InnerComponent)] directives: [forwardRef(() => InnerComponent)]
@ -662,8 +662,8 @@ class OuterWithIndirectNestedComponent {
class OuterComponent { class OuterComponent {
} }
@Component({selector: 'inner'}) @Component({
@View({ selector: 'inner',
template: template:
'INNER(<innerinner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></innerinner>)', 'INNER(<innerinner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></innerinner>)',
directives: [forwardRef(() => InnerInnerComponent)] directives: [forwardRef(() => InnerInnerComponent)]
@ -671,16 +671,16 @@ class OuterComponent {
class InnerComponent { class InnerComponent {
} }
@Component({selector: 'innerinner'}) @Component({
@View({ selector: 'innerinner',
template: 'INNERINNER(<ng-content select=".left"></ng-content>,<ng-content></ng-content>)', template: 'INNERINNER(<ng-content select=".left"></ng-content>,<ng-content></ng-content>)',
directives: [] directives: []
}) })
class InnerInnerComponent { class InnerInnerComponent {
} }
@Component({selector: 'conditional-content'}) @Component({
@View({ selector: 'conditional-content',
template: template:
'<div>(<div *manual><ng-content select=".left"></ng-content></div>, <ng-content></ng-content>)</div>', '<div>(<div *manual><ng-content select=".left"></ng-content></div>, <ng-content></ng-content>)</div>',
directives: [ManualViewportDirective] directives: [ManualViewportDirective]
@ -688,8 +688,8 @@ class InnerInnerComponent {
class ConditionalContentComponent { class ConditionalContentComponent {
} }
@Component({selector: 'conditional-text'}) @Component({
@View({ selector: 'conditional-text',
template: template:
'MAIN(<template manual>FIRST(<template manual>SECOND(<ng-content></ng-content>)</template>)</template>)', 'MAIN(<template manual>FIRST(<template manual>SECOND(<ng-content></ng-content>)</template>)</template>)',
directives: [ManualViewportDirective] directives: [ManualViewportDirective]
@ -697,16 +697,17 @@ class ConditionalContentComponent {
class ConditionalTextComponent { class ConditionalTextComponent {
} }
@Component({selector: 'tab'}) @Component({
@View({ selector: 'tab',
template: '<div><div *manual>TAB(<ng-content></ng-content>)</div></div>', template: '<div><div *manual>TAB(<ng-content></ng-content>)</div></div>',
directives: [ManualViewportDirective] directives: [ManualViewportDirective]
}) })
class Tab { class Tab {
} }
@Component({selector: 'tree', inputs: ['depth']}) @Component({
@View({ selector: 'tree',
inputs: ['depth'],
template: 'TREE({{depth}}:<tree *manual [depth]="depth+1"></tree>)', template: 'TREE({{depth}}:<tree *manual [depth]="depth+1"></tree>)',
directives: [ManualViewportDirective, Tree] directives: [ManualViewportDirective, Tree]
}) })
@ -715,8 +716,7 @@ class Tree {
} }
@Component({selector: 'cmp-d'}) @Component({selector: 'cmp-d', template: `<d>{{tagName}}</d>`})
@View({template: `<d>{{tagName}}</d>`})
class CmpD { class CmpD {
tagName: string; tagName: string;
constructor(elementRef: ElementRef) { constructor(elementRef: ElementRef) {
@ -725,8 +725,7 @@ class CmpD {
} }
@Component({selector: 'cmp-c'}) @Component({selector: 'cmp-c', template: `<c>{{tagName}}</c>`})
@View({template: `<c>{{tagName}}</c>`})
class CmpC { class CmpC {
tagName: string; tagName: string;
constructor(elementRef: ElementRef) { constructor(elementRef: ElementRef) {
@ -735,43 +734,37 @@ class CmpC {
} }
@Component({selector: 'cmp-b'}) @Component({selector: 'cmp-b', template: `<ng-content></ng-content><cmp-d></cmp-d>`, directives: [CmpD]})
@View({template: `<ng-content></ng-content><cmp-d></cmp-d>`, directives: [CmpD]})
class CmpB { class CmpB {
} }
@Component({selector: 'cmp-a'}) @Component({selector: 'cmp-a', template: `<ng-content></ng-content><cmp-c></cmp-c>`, directives: [CmpC]})
@View({template: `<ng-content></ng-content><cmp-c></cmp-c>`, directives: [CmpC]})
class CmpA { class CmpA {
} }
@Component({selector: 'cmp-b11'}) @Component({selector: 'cmp-b11', template: `{{'b11'}}`, directives: []})
@View({template: `{{'b11'}}`, directives: []})
class CmpB11 { class CmpB11 {
} }
@Component({selector: 'cmp-b12'}) @Component({selector: 'cmp-b12', template: `{{'b12'}}`, directives: []})
@View({template: `{{'b12'}}`, directives: []})
class CmpB12 { class CmpB12 {
} }
@Component({selector: 'cmp-b21'}) @Component({selector: 'cmp-b21', template: `{{'b21'}}`, directives: []})
@View({template: `{{'b21'}}`, directives: []})
class CmpB21 { class CmpB21 {
} }
@Component({selector: 'cmp-b22'}) @Component({selector: 'cmp-b22', template: `{{'b22'}}`, directives: []})
@View({template: `{{'b22'}}`, directives: []})
class CmpB22 { class CmpB22 {
} }
@Component({selector: 'cmp-a1'}) @Component(
@View({template: `{{'a1'}}<cmp-b11></cmp-b11><cmp-b12></cmp-b12>`, directives: [CmpB11, CmpB12]}) {selector: 'cmp-a1', template: `{{'a1'}}<cmp-b11></cmp-b11><cmp-b12></cmp-b12>`, directives: [CmpB11, CmpB12]})
class CmpA1 { class CmpA1 {
} }
@Component({selector: 'cmp-a2'}) @Component(
@View({template: `{{'a2'}}<cmp-b21></cmp-b21><cmp-b22></cmp-b22>`, directives: [CmpB21, CmpB22]}) {selector: 'cmp-a2', template: `{{'a2'}}<cmp-b21></cmp-b21><cmp-b22></cmp-b22>`, directives: [CmpB21, CmpB22]})
class CmpA2 { class CmpA2 {
} }

View File

@ -23,7 +23,6 @@ import {
TemplateRef, TemplateRef,
Query, Query,
QueryList, QueryList,
View,
ViewQuery, ViewQuery,
ContentChildren, ContentChildren,
ViewChildren, ViewChildren,
@ -693,8 +692,7 @@ class TextDirective {
constructor() {} constructor() {}
} }
@Component({selector: 'needs-content-children'}) @Component({selector: 'needs-content-children', template: ''})
@View({template: ''})
class NeedsContentChildren implements AfterContentInit { class NeedsContentChildren implements AfterContentInit {
@ContentChildren(TextDirective) textDirChildren: QueryList<TextDirective>; @ContentChildren(TextDirective) textDirChildren: QueryList<TextDirective>;
numberOfChildrenAfterContentInit: number; numberOfChildrenAfterContentInit: number;
@ -702,8 +700,8 @@ class NeedsContentChildren implements AfterContentInit {
ngAfterContentInit() { this.numberOfChildrenAfterContentInit = this.textDirChildren.length; } ngAfterContentInit() { this.numberOfChildrenAfterContentInit = this.textDirChildren.length; }
} }
@Component({selector: 'needs-view-children'}) @Component(
@View({template: '<div text></div>', directives: [TextDirective]}) {selector: 'needs-view-children', template: '<div text></div>', directives: [TextDirective]})
class NeedsViewChildren implements AfterViewInit { class NeedsViewChildren implements AfterViewInit {
@ViewChildren(TextDirective) textDirChildren: QueryList<TextDirective>; @ViewChildren(TextDirective) textDirChildren: QueryList<TextDirective>;
numberOfChildrenAfterViewInit: number; numberOfChildrenAfterViewInit: number;
@ -711,8 +709,7 @@ class NeedsViewChildren implements AfterViewInit {
ngAfterViewInit() { this.numberOfChildrenAfterViewInit = this.textDirChildren.length; } ngAfterViewInit() { this.numberOfChildrenAfterViewInit = this.textDirChildren.length; }
} }
@Component({selector: 'needs-content-child'}) @Component({selector: 'needs-content-child', template: ''})
@View({template: ''})
class NeedsContentChild implements AfterContentInit, AfterContentChecked { class NeedsContentChild implements AfterContentInit, AfterContentChecked {
_child: TextDirective; _child: TextDirective;
@ -732,8 +729,8 @@ class NeedsContentChild implements AfterContentInit, AfterContentChecked {
} }
} }
@Component({selector: 'needs-view-child'}) @Component({
@View({ selector: 'needs-view-child',
template: ` template: `
<div *ngIf="shouldShow" text="foo"></div> <div *ngIf="shouldShow" text="foo"></div>
`, `,
@ -764,8 +761,8 @@ class InertDirective {
constructor() {} constructor() {}
} }
@Component({selector: 'needs-query'}) @Component({
@View({ selector: 'needs-query',
directives: [NgFor, TextDirective], directives: [NgFor, TextDirective],
template: '<div text="ignoreme"></div><b *ngFor="var dir of query">{{dir.text}}|</b>' template: '<div text="ignoreme"></div><b *ngFor="var dir of query">{{dir.text}}|</b>'
}) })
@ -775,8 +772,7 @@ class NeedsQuery {
constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; } constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
} }
@Component({selector: 'needs-four-queries'}) @Component({selector: 'needs-four-queries', template: ''})
@View({template: ''})
class NeedsFourQueries { class NeedsFourQueries {
@ContentChild(TextDirective) query1: TextDirective; @ContentChild(TextDirective) query1: TextDirective;
@ContentChild(TextDirective) query2: TextDirective; @ContentChild(TextDirective) query2: TextDirective;
@ -784,8 +780,11 @@ class NeedsFourQueries {
@ContentChild(TextDirective) query4: TextDirective; @ContentChild(TextDirective) query4: TextDirective;
} }
@Component({selector: 'needs-query-desc'}) @Component({
@View({directives: [NgFor], template: '<div *ngFor="var dir of query">{{dir.text}}|</div>'}) selector: 'needs-query-desc',
directives: [NgFor],
template: '<div *ngFor="var dir of query">{{dir.text}}|</div>'
})
@Injectable() @Injectable()
class NeedsQueryDesc { class NeedsQueryDesc {
query: QueryList<TextDirective>; query: QueryList<TextDirective>;
@ -794,8 +793,7 @@ class NeedsQueryDesc {
} }
} }
@Component({selector: 'needs-query-by-var-binding'}) @Component({selector: 'needs-query-by-var-binding', directives: [], template: '<ng-content>'})
@View({directives: [], template: '<ng-content>'})
@Injectable() @Injectable()
class NeedsQueryByLabel { class NeedsQueryByLabel {
query: QueryList<any>; query: QueryList<any>;
@ -804,16 +802,18 @@ class NeedsQueryByLabel {
} }
} }
@Component({selector: 'needs-view-query-by-var-binding'}) @Component({
@View({directives: [], template: '<div #textLabel>text</div>'}) selector: 'needs-view-query-by-var-binding',
directives: [],
template: '<div #textLabel>text</div>'
})
@Injectable() @Injectable()
class NeedsViewQueryByLabel { class NeedsViewQueryByLabel {
query: QueryList<any>; query: QueryList<any>;
constructor(@ViewQuery("textLabel") query: QueryList<any>) { this.query = query; } constructor(@ViewQuery("textLabel") query: QueryList<any>) { this.query = query; }
} }
@Component({selector: 'needs-query-by-var-bindings'}) @Component({selector: 'needs-query-by-var-bindings', directives: [], template: '<ng-content>'})
@View({directives: [], template: '<ng-content>'})
@Injectable() @Injectable()
class NeedsQueryByTwoLabels { class NeedsQueryByTwoLabels {
query: QueryList<any>; query: QueryList<any>;
@ -822,8 +822,8 @@ class NeedsQueryByTwoLabels {
} }
} }
@Component({selector: 'needs-query-and-project'}) @Component({
@View({ selector: 'needs-query-and-project',
directives: [NgFor], directives: [NgFor],
template: '<div *ngFor="var dir of query">{{dir.text}}|</div><ng-content></ng-content>' template: '<div *ngFor="var dir of query">{{dir.text}}|</div><ng-content></ng-content>'
}) })
@ -833,8 +833,8 @@ class NeedsQueryAndProject {
constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; } constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
} }
@Component({selector: 'needs-view-query'}) @Component({
@View({ selector: 'needs-view-query',
directives: [TextDirective], directives: [TextDirective],
template: '<div text="1"><div text="2"></div></div>' + template: '<div text="1"><div text="2"></div></div>' +
'<div text="3"></div><div text="4"></div>' '<div text="3"></div><div text="4"></div>'
@ -845,8 +845,11 @@ class NeedsViewQuery {
constructor(@ViewQuery(TextDirective) query: QueryList<TextDirective>) { this.query = query; } constructor(@ViewQuery(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
} }
@Component({selector: 'needs-view-query-if'}) @Component({
@View({directives: [NgIf, TextDirective], template: '<div *ngIf="show" text="1"></div>'}) selector: 'needs-view-query-if',
directives: [NgIf, TextDirective],
template: '<div *ngIf="show" text="1"></div>'
})
@Injectable() @Injectable()
class NeedsViewQueryIf { class NeedsViewQueryIf {
show: boolean; show: boolean;
@ -858,8 +861,8 @@ class NeedsViewQueryIf {
} }
@Component({selector: 'needs-view-query-nested-if'}) @Component({
@View({ selector: 'needs-view-query-nested-if',
directives: [NgIf, InertDirective, TextDirective], directives: [NgIf, InertDirective, TextDirective],
template: '<div text="1"><div *ngIf="show"><div dir></div></div></div>' template: '<div text="1"><div *ngIf="show"><div dir></div></div></div>'
}) })
@ -873,8 +876,8 @@ class NeedsViewQueryNestedIf {
} }
} }
@Component({selector: 'needs-view-query-order'}) @Component({
@View({ selector: 'needs-view-query-order',
directives: [NgFor, TextDirective, InertDirective], directives: [NgFor, TextDirective, InertDirective],
template: '<div text="1"></div>' + template: '<div text="1"></div>' +
'<div *ngFor="var i of list" [text]="i"></div>' + '<div *ngFor="var i of list" [text]="i"></div>' +
@ -890,8 +893,8 @@ class NeedsViewQueryOrder {
} }
} }
@Component({selector: 'needs-view-query-order-with-p'}) @Component({
@View({ selector: 'needs-view-query-order-with-p',
directives: [NgFor, TextDirective, InertDirective], directives: [NgFor, TextDirective, InertDirective],
template: '<div dir><div text="1"></div>' + template: '<div dir><div text="1"></div>' +
'<div *ngFor="var i of list" [text]="i"></div>' + '<div *ngFor="var i of list" [text]="i"></div>' +
@ -907,8 +910,7 @@ class NeedsViewQueryOrderWithParent {
} }
} }
@Component({selector: 'needs-tpl'}) @Component({selector: 'needs-tpl', template: '<template var-x="shadow"></template>'})
@View({template: '<template var-x="shadow"></template>'})
class NeedsTpl { class NeedsTpl {
viewQuery: QueryList<TemplateRef>; viewQuery: QueryList<TemplateRef>;
query: QueryList<TemplateRef>; query: QueryList<TemplateRef>;
@ -919,8 +921,8 @@ class NeedsTpl {
} }
} }
@Component({selector: 'my-comp'}) @Component({
@View({ selector: 'my-comp',
directives: [ directives: [
NeedsQuery, NeedsQuery,
NeedsQueryDesc, NeedsQueryDesc,
@ -943,7 +945,8 @@ class NeedsTpl {
NgIf, NgIf,
NgFor, NgFor,
NeedsFourQueries NeedsFourQueries
] ],
template: ''
}) })
@Injectable() @Injectable()
class MyComp { class MyComp {

View File

@ -1,13 +1,17 @@
import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/testing_internal'; import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/testing_internal';
import {ViewResolver} from 'angular2/src/core/linker/view_resolver'; import {ViewResolver} from 'angular2/src/core/linker/view_resolver';
import {Component, View, ViewMetadata} from 'angular2/src/core/metadata'; import {Component, ViewMetadata} from 'angular2/src/core/metadata';
class SomeDir {} class SomeDir {}
class SomePipe {} class SomePipe {}
@Component({selector: 'sample'}) @Component({
@View( selector: 'sample',
{template: "some template", directives: [SomeDir], pipes: [SomePipe], styles: ["some styles"]}) template: "some template",
directives: [SomeDir],
pipes: [SomePipe],
styles: ["some styles"]
})
class ComponentWithView { class ComponentWithView {
} }
@ -22,12 +26,10 @@ class ComponentWithTemplate {
} }
@Component({selector: 'sample', template: "some template"}) @Component({selector: 'sample', template: "some template"})
@View({template: "some template"})
class ComponentWithViewTemplate { class ComponentWithViewTemplate {
} }
@Component({selector: 'sample', templateUrl: "some template url"}) @Component({selector: 'sample', templateUrl: "some template url", template: "some template"})
@View({template: "some template"})
class ComponentWithViewTemplateUrl { class ComponentWithViewTemplateUrl {
} }
@ -35,9 +37,6 @@ class ComponentWithViewTemplateUrl {
class ComponentWithoutView { class ComponentWithoutView {
} }
@View({template: "some template"})
class ClassWithView {
}
class SimpleClass {} class SimpleClass {}
@ -47,17 +46,6 @@ export function main() {
beforeEach(() => { resolver = new ViewResolver(); }); beforeEach(() => { resolver = new ViewResolver(); });
it('should read out the View metadata', () => {
var viewMetadata = resolver.resolve(ComponentWithView);
expect(viewMetadata)
.toEqual(new View({
template: "some template",
directives: [SomeDir],
pipes: [SomePipe],
styles: ["some styles"]
}));
});
it('should read out the View metadata from the Component metadata', () => { it('should read out the View metadata from the Component metadata', () => {
var viewMetadata = resolver.resolve(ComponentWithTemplate); var viewMetadata = resolver.resolve(ComponentWithTemplate);
expect(viewMetadata) expect(viewMetadata)
@ -69,32 +57,15 @@ export function main() {
})); }));
}); });
it('should read out the View metadata from a simple class', () => {
var viewMetadata = resolver.resolve(ClassWithView);
expect(viewMetadata).toEqual(new View({template: "some template"}));
});
it('should throw when Component.template is specified together with the View metadata', () => {
expect(() => resolver.resolve(ComponentWithViewTemplate))
.toThrowErrorWith(
"Component 'ComponentWithViewTemplate' cannot have both 'template' and '@View' set at the same time");
});
it('should throw when Component.template is specified together with the View metadata', () => {
expect(() => resolver.resolve(ComponentWithViewTemplateUrl))
.toThrowErrorWith(
"Component 'ComponentWithViewTemplateUrl' cannot have both 'templateUrl' and '@View' set at the same time");
});
it('should throw when Component has no View decorator and no template is set', () => { it('should throw when Component has no View decorator and no template is set', () => {
expect(() => resolver.resolve(ComponentWithoutView)) expect(() => resolver.resolve(ComponentWithoutView))
.toThrowErrorWith( .toThrowErrorWith(
"Component 'ComponentWithoutView' must have either 'template', 'templateUrl', or '@View' set"); "Component 'ComponentWithoutView' must have either 'template' or 'templateUrl' set");
}); });
it('should throw when simple class has no View decorator and no template is set', () => { it('should throw when simple class has no View decorator and no template is set', () => {
expect(() => resolver.resolve(SimpleClass)) expect(() => resolver.resolve(SimpleClass))
.toThrowErrorWith("No View decorator found on component 'SimpleClass'"); .toThrowErrorWith("Could not compile 'SimpleClass' because it is not a component.");
}); });
}); });
} }

View File

@ -10,7 +10,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View, Directive} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
import {reflector} from 'angular2/src/core/reflection/reflection'; import {reflector} from 'angular2/src/core/reflection/reflection';
export function main() { export function main() {

View File

@ -12,7 +12,7 @@ import {stringify} from 'angular2/src/facade/lang';
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock'; import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
import {Component, View, ViewMetadata} from 'angular2/src/core/metadata'; import {Component, ViewMetadata} from 'angular2/src/core/metadata';
import {isBlank} from 'angular2/src/facade/lang'; import {isBlank} from 'angular2/src/facade/lang';
@ -108,8 +108,8 @@ export function main() {
class SomeDirective {} class SomeDirective {}
@Component({selector: 'cmp'}) @Component({
@View({ selector: 'cmp',
template: 'template', template: 'template',
directives: [SomeDirective], directives: [SomeDirective],
}) })

View File

@ -16,7 +16,7 @@ import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
import {ApplicationRef} from 'angular2/src/core/application_ref'; import {ApplicationRef} from 'angular2/src/core/application_ref';
import {Console} from 'angular2/src/core/console'; import {Console} from 'angular2/src/core/console';
import {Component, Directive, View, OnDestroy, platform} from 'angular2/core'; import {Component, Directive, OnDestroy, platform} from 'angular2/core';
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser'; import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens'; import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
@ -27,36 +27,31 @@ import {ExceptionHandler} from 'angular2/src/facade/exceptions';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability'; import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {ComponentRef_, ComponentRef} from "angular2/src/core/linker/dynamic_component_loader"; import {ComponentRef_, ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app', template: '{{greeting}} world!'})
@View({template: '{{greeting}} world!'})
class HelloRootCmp { class HelloRootCmp {
greeting: string; greeting: string;
constructor() { this.greeting = 'hello'; } constructor() { this.greeting = 'hello'; }
} }
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app', template: 'before: <ng-content></ng-content> after: done'})
@View({template: 'before: <ng-content></ng-content> after: done'})
class HelloRootCmpContent { class HelloRootCmpContent {
constructor() {} constructor() {}
} }
@Component({selector: 'hello-app-2'}) @Component({selector: 'hello-app-2', template: '{{greeting}} world, again!'})
@View({template: '{{greeting}} world, again!'})
class HelloRootCmp2 { class HelloRootCmp2 {
greeting: string; greeting: string;
constructor() { this.greeting = 'hello'; } constructor() { this.greeting = 'hello'; }
} }
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app', template: ''})
@View({template: ''})
class HelloRootCmp3 { class HelloRootCmp3 {
appBinding; appBinding;
constructor(@Inject("appBinding") appBinding) { this.appBinding = appBinding; } constructor(@Inject("appBinding") appBinding) { this.appBinding = appBinding; }
} }
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app', template: ''})
@View({template: ''})
class HelloRootCmp4 { class HelloRootCmp4 {
appRef; appRef;
@ -71,8 +66,7 @@ class HelloRootMissingTemplate {
class HelloRootDirectiveIsNotCmp { class HelloRootDirectiveIsNotCmp {
} }
@Component({selector: 'hello-app'}) @Component({selector: 'hello-app', template: ''})
@View({template: ''})
class HelloOnDestroyTickCmp implements OnDestroy { class HelloOnDestroyTickCmp implements OnDestroy {
appRef: ApplicationRef; appRef: ApplicationRef;
constructor(@Inject(ApplicationRef) appRef) { this.appRef = appRef; } constructor(@Inject(ApplicationRef) appRef) { this.appRef = appRef; }

View File

@ -222,7 +222,16 @@ var NG_CORE = [
'setTestabilityGetter', 'setTestabilityGetter',
'Type', 'Type',
'PACKAGE_ROOT_URL', 'PACKAGE_ROOT_URL',
'View', 'View:dart',
/*
'View.directives:dart',
'View.encapsulation:dart',
'View.pipes:dart',
'View.styleUrls:dart',
'View.styles:dart',
'View.template:dart',
'View.templateUrl:dart',
*/
'ViewChild', 'ViewChild',
'ViewChildMetadata', 'ViewChildMetadata',
'ViewChildren', 'ViewChildren',

View File

@ -16,7 +16,7 @@ import {
import {SpyRouter, SpyLocation} from '../spies'; import {SpyRouter, SpyLocation} from '../spies';
import {provide, Component, View} from 'angular2/core'; import {provide, Component} from 'angular2/core';
import {By} from 'angular2/platform/common_dom'; import {By} from 'angular2/platform/common_dom';
import { import {
@ -102,15 +102,14 @@ export function main() {
}); });
} }
@Component({selector: 'user-cmp'}) @Component({selector: 'user-cmp', template: "hello {{user}}"})
@View({template: "hello {{user}}"})
class UserCmp { class UserCmp {
user: string; user: string;
constructor(params: RouteParams) { this.user = params.get('name'); } constructor(params: RouteParams) { this.user = params.get('name'); }
} }
@Component({selector: 'test-component'}) @Component({
@View({ selector: 'test-component',
template: ` template: `
<div> <div>
<a [routerLink]="['/Detail']" <a [routerLink]="['/Detail']"

View File

@ -15,7 +15,7 @@ import {
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, View} from 'angular2/src/core/metadata'; import {Component, Directive} from 'angular2/src/core/metadata';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Console} from 'angular2/src/core/console'; import {Console} from 'angular2/src/core/console';
import {provide, ViewChild, AfterViewInit} from 'angular2/core'; import {provide, ViewChild, AfterViewInit} from 'angular2/core';

View File

@ -15,7 +15,7 @@ import {
xit xit
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {provide, Component, Injector, Inject, View} from 'angular2/core'; import {provide, Component, Injector, Inject} from 'angular2/core';
import {isPresent} from 'angular2/src/facade/lang'; import {isPresent} from 'angular2/src/facade/lang';
import { import {
PromiseWrapper, PromiseWrapper,

View File

@ -15,7 +15,7 @@ import {
xit xit
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {provide, Component, View, Injector, Inject} from 'angular2/core'; import {provide, Component, Injector, Inject} from 'angular2/core';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';
import {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router'; import {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router';

View File

@ -22,7 +22,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
import {provide, Component, View, DirectiveResolver} from 'angular2/core'; import {provide, Component, DirectiveResolver} from 'angular2/core';
import {SpyLocation} from 'angular2/src/mock/location_mock'; import {SpyLocation} from 'angular2/src/mock/location_mock';
import { import {
@ -69,10 +69,7 @@ export function main() {
})); }));
function compile(template: string = "<router-outlet></router-outlet>") { function compile(template: string = "<router-outlet></router-outlet>") {
return tcb.overrideView(MyComp, new View({ return tcb.overrideTemplate(MyComp, ('<div>' + template + '</div>'))
template: ('<div>' + template + '</div>'),
directives: [RouterOutlet, RouterLink]
}))
.createAsync(MyComp) .createAsync(MyComp)
.then((tc) => { fixture = tc; }); .then((tc) => { fixture = tc; });
} }
@ -382,7 +379,7 @@ function getHref(tc: ComponentFixture) {
return DOM.getAttribute(tc.debugElement.query(By.css('a')).nativeElement, 'href'); return DOM.getAttribute(tc.debugElement.query(By.css('a')).nativeElement, 'href');
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp', template: '', directives: [ROUTER_DIRECTIVES]})
class MyComp { class MyComp {
name; name;
} }

View File

@ -1,4 +1,4 @@
import {provide, Provider, Component, View} from 'angular2/core'; import {provide, Provider, Component} from 'angular2/core';
import {Type, isBlank} from 'angular2/src/facade/lang'; import {Type, isBlank} from 'angular2/src/facade/lang';
import {BaseException} from 'angular2/src/facade/exceptions'; import {BaseException} from 'angular2/src/facade/exceptions';

View File

@ -12,7 +12,7 @@ import {
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, View} from 'angular2/src/core/metadata'; import {Component, Directive} from 'angular2/src/core/metadata';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Console} from 'angular2/src/core/console'; import {Console} from 'angular2/src/core/console';
import {provide} from 'angular2/core'; import {provide} from 'angular2/core';
@ -213,13 +213,15 @@ export function main() {
} }
@Component({selector: 'hello-cmp'}) @Component({selector: 'hello-cmp', template: 'hello'})
@View({template: 'hello'})
class HelloCmp { class HelloCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([ @RouteConfig([
{path: '/before', redirectTo: ['Hello']}, {path: '/before', redirectTo: ['Hello']},
{path: '/after', component: HelloCmp, name: 'Hello'} {path: '/after', component: HelloCmp, name: 'Hello'}
@ -232,8 +234,11 @@ function HelloLoader(): Promise<any> {
return Promise.resolve(HelloCmp); return Promise.resolve(HelloCmp);
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([ @RouteConfig([
{path: '/hello', component: {type: 'loader', loader: HelloLoader}}, {path: '/hello', component: {type: 'loader', loader: HelloLoader}},
]) ])
@ -241,8 +246,11 @@ class AsyncAppCmp {
constructor(public router: Router, public location: LocationStrategy) {} constructor(public router: Router, public location: LocationStrategy) {}
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([ @RouteConfig([
{path: '/hello', loader: HelloLoader}, {path: '/hello', loader: HelloLoader},
]) ])
@ -250,15 +258,21 @@ class ConciseAsyncAppCmp {
constructor(public router: Router, public location: LocationStrategy) {} constructor(public router: Router, public location: LocationStrategy) {}
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> } aside { <router-outlet name="aside"></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> } aside { <router-outlet name="aside"></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/hello', component: HelloCmp}, {aux: 'aside', component: HelloCmp}]) @RouteConfig([{path: '/hello', component: HelloCmp}, {aux: 'aside', component: HelloCmp}])
class AuxAppCmp { class AuxAppCmp {
constructor(public router: Router, public location: LocationStrategy) {} constructor(public router: Router, public location: LocationStrategy) {}
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([ @RouteConfig([
{path: '/hello', component: {type: 'constructor', constructor: HelloCmp}}, {path: '/hello', component: {type: 'constructor', constructor: HelloCmp}},
]) ])
@ -266,45 +280,66 @@ class ExplicitConstructorAppCmp {
constructor(public router: Router, public location: LocationStrategy) {} constructor(public router: Router, public location: LocationStrategy) {}
} }
@Component({selector: 'parent-cmp'}) @Component({
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'parent-cmp',
template: `parent { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp}]) @RouteConfig([{path: '/child', component: HelloCmp}])
class ParentCmp { class ParentCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/parent/...', component: ParentCmp}]) @RouteConfig([{path: '/parent/...', component: ParentCmp}])
class HierarchyAppCmp { class HierarchyAppCmp {
constructor(public router: Router, public location: LocationStrategy) {} constructor(public router: Router, public location: LocationStrategy) {}
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/hello'}]) @RouteConfig([{path: '/hello'}])
class WrongConfigCmp { class WrongConfigCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp, name: 'child'}]) @RouteConfig([{path: '/child', component: HelloCmp, name: 'child'}])
class BadAliasNameCmp { class BadAliasNameCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp, as: 'child'}]) @RouteConfig([{path: '/child', component: HelloCmp, as: 'child'}])
class BadAliasCmp { class BadAliasCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp, as: 'Child', name: 'Child'}]) @RouteConfig([{path: '/child', component: HelloCmp, as: 'Child', name: 'Child'}])
class MultipleAliasCmp { class MultipleAliasCmp {
} }
@Component({selector: 'app-cmp'}) @Component({
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES}) selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([ @RouteConfig([
{path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}}, {path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}},
]) ])

View File

@ -16,43 +16,47 @@ import {
import {Injectable, provide} from 'angular2/core'; import {Injectable, provide} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {Directive, Component, View, ViewMetadata} from 'angular2/src/core/metadata'; import {Directive, Component, ViewMetadata} from 'angular2/src/core/metadata';
@Component({selector: 'child-comp'}) @Component(
@View({template: `<span>Original {{childBinding}}</span>`, directives: []}) {selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`, directives: []})
@Injectable() @Injectable()
class ChildComp { class ChildComp {
childBinding: string; childBinding: string;
constructor() { this.childBinding = 'Child'; } constructor() { this.childBinding = 'Child'; }
} }
@Component({selector: 'child-comp'}) @Component({selector: 'child-comp', template: `<span>Mock</span>`})
@View({template: `<span>Mock</span>`})
@Injectable() @Injectable()
class MockChildComp { class MockChildComp {
} }
@Component({selector: 'parent-comp'}) @Component({
@View({template: `Parent(<child-comp></child-comp>)`, directives: [ChildComp]}) selector: 'parent-comp',
template: `Parent(<child-comp></child-comp>)`,
directives: [ChildComp]
})
@Injectable() @Injectable()
class ParentComp { class ParentComp {
} }
@Component({selector: 'my-if-comp'}) @Component({
@View({template: `MyIf(<span *ngIf="showMore">More</span>)`, directives: [NgIf]}) selector: 'my-if-comp',
template: `MyIf(<span *ngIf="showMore">More</span>)`,
directives: [NgIf]
})
@Injectable() @Injectable()
class MyIfComp { class MyIfComp {
showMore: boolean = false; showMore: boolean = false;
} }
@Component({selector: 'child-child-comp'}) @Component({selector: 'child-child-comp', template: `<span>ChildChild</span>`})
@View({template: `<span>ChildChild</span>`})
@Injectable() @Injectable()
class ChildChildComp { class ChildChildComp {
} }
@Component({selector: 'child-comp'}) @Component({
@View({ selector: 'child-comp',
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`, template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
directives: [ChildChildComp] directives: [ChildChildComp]
}) })
@ -62,8 +66,7 @@ class ChildWithChildComp {
constructor() { this.childBinding = 'Child'; } constructor() { this.childBinding = 'Child'; }
} }
@Component({selector: 'child-child-comp'}) @Component({selector: 'child-child-comp', template: `<span>ChildChild Mock</span>`})
@View({template: `<span>ChildChild Mock</span>`})
@Injectable() @Injectable()
class MockChildChildComp { class MockChildChildComp {
} }
@ -78,14 +81,20 @@ class MockFancyService extends FancyService {
value: string = 'mocked out value'; value: string = 'mocked out value';
} }
@Component({selector: 'my-service-comp', bindings: [FancyService]}) @Component({
@View({template: `injected value: {{fancyService.value}}`}) selector: 'my-service-comp',
bindings: [FancyService],
template: `injected value: {{fancyService.value}}`
})
class TestBindingsComp { class TestBindingsComp {
constructor(private fancyService: FancyService) {} constructor(private fancyService: FancyService) {}
} }
@Component({selector: 'my-service-comp', viewProviders: [FancyService]}) @Component({
@View({template: `injected value: {{fancyService.value}}`}) selector: 'my-service-comp',
viewProviders: [FancyService],
template: `injected value: {{fancyService.value}}`
})
class TestViewBindingsComp { class TestViewBindingsComp {
constructor(private fancyService: FancyService) {} constructor(private fancyService: FancyService) {}
} }

View File

@ -18,48 +18,52 @@ import {
import {Injectable, bind} from 'angular2/core'; import {Injectable, bind} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {Directive, Component, View, ViewMetadata} from 'angular2/core'; import {Directive, Component, ViewMetadata} from 'angular2/core';
import {PromiseWrapper} from 'angular2/src/facade/promise'; import {PromiseWrapper} from 'angular2/src/facade/promise';
import {XHR} from 'angular2/src/compiler/xhr'; import {XHR} from 'angular2/src/compiler/xhr';
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl'; import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
// Services, and components for the tests. // Services, and components for the tests.
@Component({selector: 'child-comp'}) @Component(
@View({template: `<span>Original {{childBinding}}</span>`, directives: []}) {selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`, directives: []})
@Injectable() @Injectable()
class ChildComp { class ChildComp {
childBinding: string; childBinding: string;
constructor() { this.childBinding = 'Child'; } constructor() { this.childBinding = 'Child'; }
} }
@Component({selector: 'child-comp'}) @Component({selector: 'child-comp', template: `<span>Mock</span>`})
@View({template: `<span>Mock</span>`})
@Injectable() @Injectable()
class MockChildComp { class MockChildComp {
} }
@Component({selector: 'parent-comp'}) @Component({
@View({template: `Parent(<child-comp></child-comp>)`, directives: [ChildComp]}) selector: 'parent-comp',
template: `Parent(<child-comp></child-comp>)`,
directives: [ChildComp]
})
@Injectable() @Injectable()
class ParentComp { class ParentComp {
} }
@Component({selector: 'my-if-comp'}) @Component({
@View({template: `MyIf(<span *ngIf="showMore">More</span>)`, directives: [NgIf]}) selector: 'my-if-comp',
template: `MyIf(<span *ngIf="showMore">More</span>)`,
directives: [NgIf]
})
@Injectable() @Injectable()
class MyIfComp { class MyIfComp {
showMore: boolean = false; showMore: boolean = false;
} }
@Component({selector: 'child-child-comp'}) @Component({selector: 'child-child-comp', template: `<span>ChildChild</span>`})
@View({template: `<span>ChildChild</span>`})
@Injectable() @Injectable()
class ChildChildComp { class ChildChildComp {
} }
@Component({selector: 'child-comp'}) @Component({
@View({ selector: 'child-comp',
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`, template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
directives: [ChildChildComp] directives: [ChildChildComp]
}) })
@ -69,8 +73,7 @@ class ChildWithChildComp {
constructor() { this.childBinding = 'Child'; } constructor() { this.childBinding = 'Child'; }
} }
@Component({selector: 'child-child-comp'}) @Component({selector: 'child-child-comp', template: `<span>ChildChild Mock</span>`})
@View({template: `<span>ChildChild Mock</span>`})
@Injectable() @Injectable()
class MockChildChildComp { class MockChildChildComp {
} }
@ -84,25 +87,32 @@ class MockFancyService extends FancyService {
value: string = 'mocked out value'; value: string = 'mocked out value';
} }
@Component({selector: 'my-service-comp', providers: [FancyService]}) @Component({
@View({template: `injected value: {{fancyService.value}}`}) selector: 'my-service-comp',
providers: [FancyService],
template: `injected value: {{fancyService.value}}`
})
class TestProvidersComp { class TestProvidersComp {
constructor(private fancyService: FancyService) {} constructor(private fancyService: FancyService) {}
} }
@Component({selector: 'my-service-comp', viewProviders: [FancyService]}) @Component({
@View({template: `injected value: {{fancyService.value}}`}) selector: 'my-service-comp',
viewProviders: [FancyService],
template: `injected value: {{fancyService.value}}`
})
class TestViewProvidersComp { class TestViewProvidersComp {
constructor(private fancyService: FancyService) {} constructor(private fancyService: FancyService) {}
} }
@Component({selector: 'external-template-comp'}) @Component({
@View({templateUrl: '/base/modules/angular2/test/testing/static_assets/test.html'}) selector: 'external-template-comp',
templateUrl: '/base/modules/angular2/test/testing/static_assets/test.html'
})
class ExternalTemplateComp { class ExternalTemplateComp {
} }
@Component({selector: 'bad-template-comp'}) @Component({selector: 'bad-template-comp', templateUrl: 'non-existant.html'})
@View({templateUrl: 'non-existant.html'})
class BadTemplateUrl { class BadTemplateUrl {
} }

View File

@ -11,7 +11,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {getComponentInfo, parseFields} from 'angular2/src/upgrade/metadata'; import {getComponentInfo, parseFields} from 'angular2/src/upgrade/metadata';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
@ -67,13 +67,11 @@ export function main() {
}); });
} }
@Component({selector: 'element-name-dashed'}) @Component({selector: 'element-name-dashed', template: ``})
@View({template: ``})
class ElementNameComponent { class ElementNameComponent {
} }
@Component({selector: '[attr-name]'}) @Component({selector: '[attr-name]', template: ``})
@View({template: ``})
class AttributeNameComponent { class AttributeNameComponent {
} }

View File

@ -20,7 +20,6 @@ import {
Injector, Injector,
ViewMetadata, ViewMetadata,
Component, Component,
View,
Injectable, Injectable,
ElementRef ElementRef
} from 'angular2/core'; } from 'angular2/core';
@ -257,8 +256,7 @@ export function main() {
} }
@Component({selector: 'my-comp'}) @Component({selector: 'my-comp', directives: []})
@View({directives: []})
@Injectable() @Injectable()
class MyComp { class MyComp {
ctxProp: string; ctxProp: string;

View File

@ -1,4 +1,4 @@
import {Component, View, ViewEncapsulation, OnChanges} from 'angular2/core'; import {Component, ViewEncapsulation, OnChanges} from 'angular2/core';
import {TimerWrapper} from 'angular2/src/facade/async'; import {TimerWrapper} from 'angular2/src/facade/async';
import {isPresent} from 'angular2/src/facade/lang'; import {isPresent} from 'angular2/src/facade/lang';
@ -15,8 +15,6 @@ import {isPresent} from 'angular2/src/facade/lang';
'(blur)': 'onBlur()', '(blur)': 'onBlur()',
'[class.md-button-focus]': 'isKeyboardFocused', '[class.md-button-focus]': 'isKeyboardFocused',
}, },
})
@View({
templateUrl: 'package:angular2_material/src/components/button/button.html', templateUrl: 'package:angular2_material/src/components/button/button.html',
styleUrls: ['package:angular2_material/src/components/button/button.css'], styleUrls: ['package:angular2_material/src/components/button/button.css'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
@ -59,8 +57,6 @@ export class MdButton {
'[class.md-button-focus]': 'isKeyboardFocused', '[class.md-button-focus]': 'isKeyboardFocused',
'[attr.aria-disabled]': 'isAriaDisabled', '[attr.aria-disabled]': 'isAriaDisabled',
}, },
})
@View({
templateUrl: 'package:angular2_material/src/components/button/button.html', templateUrl: 'package:angular2_material/src/components/button/button.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })

View File

@ -1,4 +1,4 @@
import {Component, View, Attribute, ViewEncapsulation} from 'angular2/core'; import {Component, Attribute, ViewEncapsulation} from 'angular2/core';
import {isPresent} from 'angular2/src/facade/lang'; import {isPresent} from 'angular2/src/facade/lang';
import {KeyCodes} from 'angular2_material/src/core/key_codes'; import {KeyCodes} from 'angular2_material/src/core/key_codes';
import {KeyboardEvent} from 'angular2/src/facade/browser'; import {KeyboardEvent} from 'angular2/src/facade/browser';
@ -13,9 +13,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
'[attr.aria-disabled]': 'disabled', '[attr.aria-disabled]': 'disabled',
'[tabindex]': 'tabindex', '[tabindex]': 'tabindex',
'(keydown)': 'onKeydown($event)', '(keydown)': 'onKeydown($event)',
} },
})
@View({
templateUrl: 'package:angular2_material/src/components/checkbox/checkbox.html', templateUrl: 'package:angular2_material/src/components/checkbox/checkbox.html',
directives: [], directives: [],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None

View File

@ -12,7 +12,6 @@ import {
ResolvedProvider, ResolvedProvider,
SkipSelf, SkipSelf,
Injector, Injector,
View,
ViewEncapsulation ViewEncapsulation
} from 'angular2/core'; } from 'angular2/core';
@ -212,8 +211,6 @@ export class MdDialogConfig {
'tabindex': '0', 'tabindex': '0',
'(body:keydown)': 'documentKeypress($event)', '(body:keydown)': 'documentKeypress($event)',
}, },
})
@View({
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
templateUrl: 'package:angular2_material/src/components/dialog/dialog.html', templateUrl: 'package:angular2_material/src/components/dialog/dialog.html',
directives: [forwardRef(() => MdDialogContent)] directives: [forwardRef(() => MdDialogContent)]
@ -261,8 +258,9 @@ class MdDialogContent {
host: { host: {
'(click)': 'onClick()', '(click)': 'onClick()',
}, },
template: '',
encapsulation: ViewEncapsulation.None
}) })
@View({template: '', encapsulation: ViewEncapsulation.None})
class MdBackdrop { class MdBackdrop {
dialogRef: MdDialogRef; dialogRef: MdDialogRef;

View File

@ -1,6 +1,5 @@
import { import {
Component, Component,
View,
ViewEncapsulation, ViewEncapsulation,
Host, Host,
SkipSelf, SkipSelf,
@ -27,8 +26,9 @@ class RowHeightMode {
} }
@Component({selector: 'md-grid-list', inputs: ['cols', 'rowHeight', 'gutterSize']}) @Component({
@View({ selector: 'md-grid-list',
inputs: ['cols', 'rowHeight', 'gutterSize'],
templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html', templateUrl: 'package:angular2_material/src/components/grid_list/grid_list.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@ -223,9 +223,7 @@ export class MdGridList implements AfterContentChecked {
'[style.left]': 'style.left', '[style.left]': 'style.left',
'[style.marginTop]': 'style.marginTop', '[style.marginTop]': 'style.marginTop',
'[style.paddingTop]': 'style.paddingTop', '[style.paddingTop]': 'style.paddingTop',
} },
})
@View({
templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html', templateUrl: 'package:angular2_material/src/components/grid_list/grid_tile.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })

View File

@ -13,7 +13,7 @@ import {
xit, xit,
} from 'angular2/testing_internal'; } from 'angular2/testing_internal';
import {Component, View, ViewMetadata, bind, provide, DebugElement} from 'angular2/core'; import {Component, ViewMetadata, bind, provide, DebugElement} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button'; import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button';
@ -114,8 +114,8 @@ function getChildDebugElement(parent: DebugElement, tagName: string): DebugEleme
} }
/** Test component that contains an MdButton. */ /** Test component that contains an MdButton. */
@Component({selector: 'test-app'}) @Component({
@View({ selector: 'test-app',
directives: [MdButton], directives: [MdButton],
template: template:
`<button mdButton type="button" (click)="increment()" [disabled]="isDisabled">Go</button>` `<button mdButton type="button" (click)="increment()" [disabled]="isDisabled">Go</button>`

View File

@ -9,7 +9,6 @@ import {
Compiler, Compiler,
Component, Component,
Directive, Directive,
View,
ViewContainerRef, ViewContainerRef,
bind, bind,
provide, provide,
@ -91,8 +90,7 @@ class MultiplyViewResolver extends ViewResolver {
} }
} }
@Component({selector: 'app'}) @Component({selector: 'app', directives: [], template: ``})
@View({directives: [], template: ``})
class CompilerAppComponent { class CompilerAppComponent {
constructor(private _compiler: Compiler) {} constructor(private _compiler: Compiler) {}
compileNoBindings() { compileNoBindings() {
@ -131,8 +129,8 @@ class Dir4 {
} }
@Component({selector: 'cmp-nobind'}) @Component({
@View({ selector: 'cmp-nobind',
directives: [Dir0, Dir1, Dir2, Dir3, Dir4], directives: [Dir0, Dir1, Dir2, Dir3, Dir4],
template: ` template: `
<div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4"> <div class="class0 class1 class2 class3 class4 " nodir0="" attr0="value0" nodir1="" attr1="value1" nodir2="" attr2="value2" nodir3="" attr3="value3" nodir4="" attr4="value4">
@ -149,8 +147,8 @@ class Dir4 {
class BenchmarkComponentNoBindings { class BenchmarkComponentNoBindings {
} }
@Component({selector: 'cmp-withbind'}) @Component({
@View({ selector: 'cmp-withbind',
directives: [Dir0, Dir1, Dir2, Dir3, Dir4], directives: [Dir0, Dir1, Dir2, Dir3, Dir4],
template: ` template: `
<div class="class0 class1 class2 class3 class4 " dir0="" [attr0]="value0" dir1="" [attr1]="value1" dir2="" [attr2]="value2" dir3="" [attr3]="value3" dir4="" [attr4]="value4"> <div class="class0 class1 class2 class3 class4 " dir0="" [attr0]="value0" dir1="" [attr1]="value1" dir2="" [attr2]="value2" dir3="" [attr3]="value3" dir4="" [attr4]="value4">

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, DynamicComponentLoader, ElementRef, View} from 'angular2/core'; import {Component, Directive, DynamicComponentLoader, ElementRef} from 'angular2/core';
import {NgIf, NgFor} from 'angular2/common'; import {NgIf, NgFor} from 'angular2/common';
import {ApplicationRef} from 'angular2/src/core/application_ref'; import {ApplicationRef} from 'angular2/src/core/application_ref';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
@ -43,8 +43,7 @@ export function main() {
} }
@Component({selector: 'dummy'}) @Component({selector: 'dummy', template: `<div></div>`})
@View({template: `<div></div>`})
class DummyComponent { class DummyComponent {
} }
@ -59,8 +58,8 @@ class DynamicDummy {
} }
} }
@Component({selector: 'app'}) @Component({
@View({ selector: 'app',
directives: [NgIf, NgFor, DummyComponent, DummyDirective, DynamicDummy], directives: [NgIf, NgFor, DummyComponent, DummyDirective, DynamicDummy],
template: ` template: `
<div *ngIf="testingPlainComponents"> <div *ngIf="testingPlainComponents">

View File

@ -8,7 +8,7 @@ import {
windowProfileEnd windowProfileEnd
} from 'angular2/src/testing/benchmark_util'; } from 'angular2/src/testing/benchmark_util';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View, bind, provide} from 'angular2/core'; import {Component, Directive, bind, provide} from 'angular2/core';
import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common'; import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common';
import {ApplicationRef} from 'angular2/src/core/application_ref'; import {ApplicationRef} from 'angular2/src/core/application_ref';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter'; import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
@ -207,8 +207,9 @@ class CellData {
iFn() { return this.i; } iFn() { return this.i; }
} }
@Component({selector: 'largetable', inputs: ['data', 'benchmarkType']}) @Component({
@View({ selector: 'largetable',
inputs: ['data', 'benchmarkType'],
directives: [NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault], directives: [NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault],
template: ` template: `
<table [ngSwitch]="benchmarkType"> <table [ngSwitch]="benchmarkType">
@ -255,8 +256,8 @@ class LargetableComponent {
} }
} }
@Component({selector: 'app'}) @Component({
@View({ selector: 'app',
directives: [LargetableComponent], directives: [LargetableComponent],
template: `<largetable [data]='data' [benchmarkType]='benchmarkType'></largetable>` template: `<largetable [data]='data' [benchmarkType]='benchmarkType'></largetable>`
}) })

View File

@ -6,11 +6,11 @@ import {NgIf, NgFor} from 'angular2/common';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {document} from 'angular2/src/facade/browser'; import {document} from 'angular2/src/facade/browser';
import {Component, Directive, View} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
@Component({selector: 'scroll-app'}) @Component({
@View({ selector: 'scroll-app',
directives: [ScrollAreaComponent, NgIf, NgFor], directives: [ScrollAreaComponent, NgIf, NgFor],
template: ` template: `
<div> <div>

View File

@ -2,7 +2,7 @@ import {ListWrapper, Map} from 'angular2/src/facade/collection';
import {Company, Opportunity, Offering, Account, CustomDate, STATUS_LIST} from './common'; import {Company, Opportunity, Offering, Account, CustomDate, STATUS_LIST} from './common';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {Component, Directive, View} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
export class HasStyle { export class HasStyle {
cellWidth: number; cellWidth: number;
@ -12,20 +12,32 @@ export class HasStyle {
set width(w: number) { this.cellWidth = w; } set width(w: number) { this.cellWidth = w; }
} }
@Component({selector: 'company-name', inputs: ['width: cell-width', 'company']}) @Component({
@View({directives: [], template: `<div [style.width.px]="cellWidth">{{company.name}}</div>`}) selector: 'company-name',
inputs: ['width: cell-width', 'company'],
directives: [],
template: `<div [style.width.px]="cellWidth">{{company.name}}</div>`
})
export class CompanyNameComponent extends HasStyle { export class CompanyNameComponent extends HasStyle {
company: Company; company: Company;
} }
@Component({selector: 'opportunity-name', inputs: ['width: cell-width', 'opportunity']}) @Component({
@View({directives: [], template: `<div [style.width.px]="cellWidth">{{opportunity.name}}</div>`}) selector: 'opportunity-name',
inputs: ['width: cell-width', 'opportunity'],
directives: [],
template: `<div [style.width.px]="cellWidth">{{opportunity.name}}</div>`
})
export class OpportunityNameComponent extends HasStyle { export class OpportunityNameComponent extends HasStyle {
opportunity: Opportunity; opportunity: Opportunity;
} }
@Component({selector: 'offering-name', inputs: ['width: cell-width', 'offering']}) @Component({
@View({directives: [], template: `<div [style.width.px]="cellWidth">{{offering.name}}</div>`}) selector: 'offering-name',
inputs: ['width: cell-width', 'offering'],
directives: [],
template: `<div [style.width.px]="cellWidth">{{offering.name}}</div>`
})
export class OfferingNameComponent extends HasStyle { export class OfferingNameComponent extends HasStyle {
offering: Offering; offering: Offering;
} }
@ -37,8 +49,9 @@ export class Stage {
apply: Function; apply: Function;
} }
@Component({selector: 'stage-buttons', inputs: ['width: cell-width', 'offering']}) @Component({
@View({ selector: 'stage-buttons',
inputs: ['width: cell-width', 'offering'],
directives: [NgFor], directives: [NgFor],
template: ` template: `
<div [style.width.px]="cellWidth"> <div [style.width.px]="cellWidth">
@ -82,8 +95,9 @@ export class StageButtonsComponent extends HasStyle {
} }
} }
@Component({selector: 'account-cell', inputs: ['width: cell-width', 'account']}) @Component({
@View({ selector: 'account-cell',
inputs: ['width: cell-width', 'account'],
directives: [], directives: [],
template: ` template: `
<div [style.width.px]="cellWidth"> <div [style.width.px]="cellWidth">
@ -96,8 +110,12 @@ export class AccountCellComponent extends HasStyle {
account: Account; account: Account;
} }
@Component({selector: 'formatted-cell', inputs: ['width: cell-width', 'value']}) @Component({
@View({directives: [], template: `<div [style.width.px]="cellWidth">{{formattedValue}}</div>`}) selector: 'formatted-cell',
inputs: ['width: cell-width', 'value'],
directives: [],
template: `<div [style.width.px]="cellWidth">{{formattedValue}}</div>`
})
export class FormattedCellComponent extends HasStyle { export class FormattedCellComponent extends HasStyle {
formattedValue: string; formattedValue: string;

View File

@ -1,7 +1,7 @@
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
import {Math} from 'angular2/src/facade/math'; import {Math} from 'angular2/src/facade/math';
import {Component, Directive, View} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
import { import {
Offering, Offering,
@ -18,8 +18,6 @@ import {NgFor} from 'angular2/common';
@Component({ @Component({
selector: 'scroll-area', selector: 'scroll-area',
})
@View({
directives: [ScrollItemComponent, NgFor], directives: [ScrollItemComponent, NgFor],
template: ` template: `
<div> <div>

View File

@ -7,7 +7,7 @@ import {
FormattedCellComponent FormattedCellComponent
} from './cells'; } from './cells';
import {Component, Directive, View} from 'angular2/core'; import {Component, Directive} from 'angular2/core';
import { import {
Offering, Offering,
@ -25,8 +25,9 @@ import {
AAT_STATUS_WIDTH AAT_STATUS_WIDTH
} from './common'; } from './common';
@Component({selector: 'scroll-item', inputs: ['offering']}) @Component({
@View({ selector: 'scroll-item',
inputs: ['offering'],
directives: [ directives: [
CompanyNameComponent, CompanyNameComponent,
OpportunityNameComponent, OpportunityNameComponent,

View File

@ -4,7 +4,6 @@ import {
Compiler, Compiler,
Component, Component,
Directive, Directive,
View,
ViewContainerRef, ViewContainerRef,
bind, bind,
provide, provide,
@ -225,21 +224,23 @@ class StaticTreeComponentBase {
get data() { return this._value; } get data() { return this._value; }
} }
@Component({selector: 'tree', inputs: ['data']}) @Component(
@View({directives: [], template: '<span>{{data.value}} </span>'}) {selector: 'tree', inputs: ['data'], directives: [], template: '<span>{{data.value}} </span>'})
class StaticTreeComponent0 extends StaticTreeComponentBase { class StaticTreeComponent0 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent0], directives: [StaticTreeComponent0],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent1 extends StaticTreeComponentBase { class StaticTreeComponent1 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent1], directives: [StaticTreeComponent1],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
@ -247,64 +248,71 @@ class StaticTreeComponent2 extends StaticTreeComponentBase {
data: TreeNode; data: TreeNode;
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent2], directives: [StaticTreeComponent2],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent3 extends StaticTreeComponentBase { class StaticTreeComponent3 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent3], directives: [StaticTreeComponent3],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent4 extends StaticTreeComponentBase { class StaticTreeComponent4 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent4], directives: [StaticTreeComponent4],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent5 extends StaticTreeComponentBase { class StaticTreeComponent5 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent5], directives: [StaticTreeComponent5],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent6 extends StaticTreeComponentBase { class StaticTreeComponent6 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent6], directives: [StaticTreeComponent6],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent7 extends StaticTreeComponentBase { class StaticTreeComponent7 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent7], directives: [StaticTreeComponent7],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent8 extends StaticTreeComponentBase { class StaticTreeComponent8 extends StaticTreeComponentBase {
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent8], directives: [StaticTreeComponent8],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>` template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent9 extends StaticTreeComponentBase { class StaticTreeComponent9 extends StaticTreeComponentBase {
} }
@Component({selector: 'app'}) @Component({
@View({ selector: 'app',
directives: [StaticTreeComponent9, NgIf], directives: [StaticTreeComponent9, NgIf],
template: `<tree *ngIf="initData != null" [data]='initData'></tree>` template: `<tree *ngIf="initData != null" [data]='initData'></tree>`
}) })

View File

@ -3,7 +3,6 @@ import {
Compiler, Compiler,
Component, Component,
Directive, Directive,
View,
ViewContainerRef, ViewContainerRef,
bind, bind,
provide, provide,
@ -217,8 +216,9 @@ class BaseLineIf {
} }
} }
@Component({selector: 'tree', inputs: ['data']}) @Component({
@View({ selector: 'tree',
inputs: ['data'],
directives: [TreeComponent, NgIf], directives: [TreeComponent, NgIf],
template: template:
`<span> {{data.value}} <span template='ngIf data.right != null'><tree [data]='data.right'></tree></span><span template='ngIf data.left != null'><tree [data]='data.left'></tree></span></span>` `<span> {{data.value}} <span template='ngIf data.right != null'><tree [data]='data.right'></tree></span><span template='ngIf data.left != null'><tree [data]='data.left'></tree></span></span>`
@ -227,8 +227,8 @@ class TreeComponent {
data: TreeNode; data: TreeNode;
} }
@Component({selector: 'app'}) @Component(
@View({directives: [TreeComponent], template: `<tree [data]='initData'></tree>`}) {selector: 'app', directives: [TreeComponent], template: `<tree [data]='initData'></tree>`})
class AppComponent { class AppComponent {
initData: TreeNode; initData: TreeNode;
constructor() { constructor() {

View File

@ -1,10 +1,10 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {TimerWrapper} from 'angular2/src/facade/async'; import {TimerWrapper} from 'angular2/src/facade/async';
@Component({selector: 'async-app'}) @Component({
@View({ selector: 'async-app',
template: ` template: `
<div id='increment'> <div id='increment'>
<span class='val'>{{val1}}</span> <span class='val'>{{val1}}</span>

View File

@ -1,8 +1,7 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
@Component({selector: 'gestures-app'}) @Component({selector: 'gestures-app', templateUrl: 'template.html'})
@View({templateUrl: 'template.html'})
class GesturesCmp { class GesturesCmp {
swipeDirection: string = '-'; swipeDirection: string = '-';
pinchScale: number = 1; pinchScale: number = 1;

View File

@ -1,9 +1,9 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events'; import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
@Component({selector: 'key-events-app'}) @Component({
@View({ selector: 'key-events-app',
template: `Click in the following area and press a key to display its name:<br> template: `Click in the following area and press a key to display its name:<br>
<div (keydown)="onKeyDown($event)" class="sample-area" tabindex="0">{{lastKey}}</div><br> <div (keydown)="onKeyDown($event)" class="sample-area" tabindex="0">{{lastKey}}</div><br>
Click in the following area and press shift.enter:<br> Click in the following area and press shift.enter:<br>

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button'; import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button';
@ -7,8 +7,6 @@ import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdButton, MdAnchor, NgFor], directives: [MdButton, MdAnchor, NgFor],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, Directive, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, Directive, ViewEncapsulation} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {MdCheckbox} from 'angular2_material/src/components/checkbox/checkbox'; import {MdCheckbox} from 'angular2_material/src/components/checkbox/checkbox';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@ -7,8 +7,6 @@ import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdCheckbox], directives: [MdCheckbox],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None

View File

@ -1,13 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import { import {bind, provide, ElementRef, ComponentRef, Component, ViewEncapsulation} from 'angular2/core';
bind,
provide,
ElementRef,
ComponentRef,
Component,
View,
ViewEncapsulation
} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import { import {
MdDialog, MdDialog,
@ -21,8 +13,6 @@ import {isPresent} from 'angular2/src/facade/lang';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
viewProviders: [MdDialog], viewProviders: [MdDialog],
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [], directives: [],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
@ -69,8 +59,6 @@ class DemoApp {
@Component({ @Component({
selector: 'simple-dialog', selector: 'simple-dialog',
inputs: ['numCoconuts'], inputs: ['numCoconuts'],
})
@View({
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
template: ` template: `
<h2>This is the dialog content</h2> <h2>This is the dialog content</h2>

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {MdGridList, MdGridTile} from 'angular2_material/src/components/grid_list/grid_list'; import {MdGridList, MdGridTile} from 'angular2_material/src/components/grid_list/grid_list';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@ -7,8 +7,6 @@ import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdGridList, MdGridTile], directives: [MdGridList, MdGridTile],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,

View File

@ -1,11 +1,11 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {MdInputContainer, MdInput} from 'angular2_material/src/components/input/input'; import {MdInputContainer, MdInput} from 'angular2_material/src/components/input/input';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({selector: 'demo-app'}) @Component({
@View({ selector: 'demo-app',
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdInputContainer, MdInput], directives: [MdInputContainer, MdInput],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None

View File

@ -1,13 +1,11 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {MdProgressLinear} from 'angular2_material/src/components/progress-linear/progress_linear'; import {MdProgressLinear} from 'angular2_material/src/components/progress-linear/progress_linear';
import {UrlResolver} from 'angular2/src/compiler/url_resolver'; import {UrlResolver} from 'angular2/src/compiler/url_resolver';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdProgressLinear], directives: [MdProgressLinear],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
import {MdRadioButton, MdRadioGroup} from 'angular2_material/src/components/radio/radio_button'; import {MdRadioButton, MdRadioGroup} from 'angular2_material/src/components/radio/radio_button';
import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher'; import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher';
@ -8,8 +8,6 @@ import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
viewProviders: [MdRadioDispatcher], viewProviders: [MdRadioDispatcher],
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdRadioGroup, MdRadioButton], directives: [MdRadioGroup, MdRadioButton],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,

View File

@ -1,13 +1,11 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, View, ViewEncapsulation} from 'angular2/core'; import {bind, provide, Component, ViewEncapsulation} from 'angular2/core';
import {MdSwitch} from 'angular2_material/src/components/switcher/switch'; import {MdSwitch} from 'angular2_material/src/components/switcher/switch';
import {UrlResolver} from 'angular2/src/compiler/url_resolver'; import {UrlResolver} from 'angular2/src/compiler/url_resolver';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common';
@Component({ @Component({
selector: 'demo-app', selector: 'demo-app',
})
@View({
templateUrl: './demo_app.html', templateUrl: './demo_app.html',
directives: [MdSwitch], directives: [MdSwitch],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,

View File

@ -9,7 +9,7 @@ import {
NgIf, NgIf,
NgFor NgFor
} from 'angular2/common'; } from 'angular2/common';
import {Component, Directive, View, Host} from 'angular2/core'; import {Component, Directive, Host} from 'angular2/core';
import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang'; import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';
import {AbstractControl} from 'angular2/common'; import {AbstractControl} from 'angular2/common';
@ -40,8 +40,9 @@ function creditCardValidator(c: AbstractControl): {[key: string]: boolean} {
* actual error message. * actual error message.
* To make it simple, we are using a simple map here. * To make it simple, we are using a simple map here.
*/ */
@Component({selector: 'show-error', inputs: ['controlPath: control', 'errorTypes: errors']}) @Component({
@View({ selector: 'show-error',
inputs: ['controlPath: control', 'errorTypes: errors'],
template: ` template: `
<span *ngIf="errorMessage !== null">{{errorMessage}}</span> <span *ngIf="errorMessage !== null">{{errorMessage}}</span>
`, `,
@ -74,8 +75,9 @@ class ShowError {
} }
@Component({selector: 'model-driven-forms', viewProviders: [FormBuilder]}) @Component({
@View({ selector: 'model-driven-forms',
viewProviders: [FormBuilder],
template: ` template: `
<h1>Checkout Form (Model Driven)</h1> <h1>Checkout Form (Model Driven)</h1>

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View, Host, forwardRef, Provider, Injectable} from 'angular2/core'; import {Component, Directive, Host, forwardRef, Provider, Injectable} from 'angular2/core';
import {NgIf, NgFor, FORM_DIRECTIVES} from 'angular2/common'; import {NgIf, NgFor, FORM_DIRECTIVES} from 'angular2/common';
import {CONST_EXPR} from 'angular2/src/facade/lang'; import {CONST_EXPR} from 'angular2/src/facade/lang';
@ -76,8 +76,8 @@ class DataService {
// ---- components // ---- components
@Component({selector: 'full-name-cmp'}) @Component({
@View({ selector: 'full-name-cmp',
template: ` template: `
<h1>Edit Full Name</h1> <h1>Edit Full Name</h1>
<div> <div>
@ -107,8 +107,8 @@ class FullNameComponent {
get person(): Person { return this._service.currentPerson; } get person(): Person { return this._service.currentPerson; }
} }
@Component({selector: 'person-detail-cmp'}) @Component({
@View({ selector: 'person-detail-cmp',
template: ` template: `
<h2>{{person.fullName}}</h2> <h2>{{person.fullName}}</h2>
@ -155,8 +155,8 @@ class PersonsDetailComponent {
get person(): Person { return this._service.currentPerson; } get person(): Person { return this._service.currentPerson; }
} }
@Component({selector: 'persons-cmp'}) @Component({
@View({ selector: 'persons-cmp',
template: ` template: `
<h1>FullName Demo</h1> <h1>FullName Demo</h1>
<div> <div>
@ -180,8 +180,9 @@ class PersonsComponent {
} }
@Component({selector: 'person-management-app', viewBindings: [DataService]}) @Component({
@View({ selector: 'person-management-app',
viewBindings: [DataService],
template: ` template: `
<button (click)="switchToEditName()">Edit Full Name</button> <button (click)="switchToEditName()">Edit Full Name</button>
<button (click)="switchToPersonList()">Person Array</button> <button (click)="switchToPersonList()">Person Array</button>

View File

@ -1,11 +1,9 @@
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions'; import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
@Component({ @Component({
selector: 'error-app', selector: 'error-app',
})
@View({
template: ` template: `
<button class="errorButton" (click)="createError()">create error</button>` <button class="errorButton" (click)="createError()">create error</button>`
}) })

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View, Host, forwardRef, Provider} from 'angular2/core'; import {Component, Directive, Host, forwardRef, Provider} from 'angular2/core';
import { import {
ControlGroup, ControlGroup,
NgIf, NgIf,
@ -61,8 +61,9 @@ class CreditCardValidator {
* actual error message. * actual error message.
* To make it simple, we are using a simple map here. * To make it simple, we are using a simple map here.
*/ */
@Component({selector: 'show-error', inputs: ['controlPath: control', 'errorTypes: errors']}) @Component({
@View({ selector: 'show-error',
inputs: ['controlPath: control', 'errorTypes: errors'],
template: ` template: `
<span *ngIf="errorMessage !== null">{{errorMessage}}</span> <span *ngIf="errorMessage !== null">{{errorMessage}}</span>
`, `,
@ -95,8 +96,8 @@ class ShowError {
} }
@Component({selector: 'template-driven-forms'}) @Component({
@View({ selector: 'template-driven-forms',
template: ` template: `
<h1>Checkout Form</h1> <h1>Checkout Form</h1>

View File

@ -1,10 +1,14 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {Store, Todo, TodoFactory} from './services/TodoStore'; import {Store, Todo, TodoFactory} from './services/TodoStore';
@Component({selector: 'todo-app', viewProviders: [Store, TodoFactory]}) @Component({
@View({templateUrl: 'todo.html', directives: [NgFor]}) selector: 'todo-app',
viewProviders: [Store, TodoFactory],
templateUrl: 'todo.html',
directives: [NgFor]
})
class TodoApp { class TodoApp {
todoEdit: Todo = null; todoEdit: Todo = null;

View File

@ -1,4 +1,4 @@
import {Renderer, ElementRef, Component, Directive, View, Injectable} from 'angular2/core'; import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core';
import {StringWrapper} from 'angular2/src/facade/lang'; import {StringWrapper} from 'angular2/src/facade/lang';
// A service available to the Injector, used by the HelloCmp component. // A service available to the Injector, used by the HelloCmp component.
@ -33,10 +33,8 @@ class RedDec {
selector: 'hello-app', selector: 'hello-app',
// These are services that would be created if a class in the component's // These are services that would be created if a class in the component's
// template tries to inject them. // template tries to inject them.
viewProviders: [GreetingService] viewProviders: [GreetingService],
}) // The template for the component.
// The template for the component.
@View({
// Expressions in the template (like {{greeting}}) are evaluated in the // Expressions in the template (like {{greeting}}) are evaluated in the
// context of the HelloCmp class below. // context of the HelloCmp class below.
template: `<div class="greeting">{{greeting}} <span red>world</span>!</div> template: `<div class="greeting">{{greeting}} <span red>world</span>!</div>

View File

@ -1,11 +1,10 @@
import {PromiseWrapper} from "angular2/src/facade/async"; import {PromiseWrapper} from "angular2/src/facade/async";
import {Component, View} from "angular2/core"; import {Component} from "angular2/core";
import {ServiceMessageBrokerFactory, PRIMITIVE} from "angular2/platform/worker_app"; import {ServiceMessageBrokerFactory, PRIMITIVE} from "angular2/platform/worker_app";
const ECHO_CHANNEL = "ECHO"; const ECHO_CHANNEL = "ECHO";
@Component({selector: 'app'}) @Component({selector: 'app', template: "<h1>WebWorker MessageBroker Test</h1>"})
@View({template: "<h1>WebWorker MessageBroker Test</h1>"})
export class App { export class App {
constructor(private _serviceBrokerFactory: ServiceMessageBrokerFactory) { constructor(private _serviceBrokerFactory: ServiceMessageBrokerFactory) {
var broker = _serviceBrokerFactory.createMessageBroker(ECHO_CHANNEL, false); var broker = _serviceBrokerFactory.createMessageBroker(ECHO_CHANNEL, false);

View File

@ -1,4 +1,4 @@
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {Start} from './components/start'; import {Start} from './components/start';
import {About} from './components/about'; import {About} from './components/about';
import {Contact} from './components/contact'; import {Contact} from './components/contact';

View File

@ -1,9 +1,13 @@
import {View, Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgFor, FORM_DIRECTIVES} from 'angular2/common'; import {NgFor, FORM_DIRECTIVES} from 'angular2/common';
import {Store, Todo, TodoFactory} from './services/TodoStore'; import {Store, Todo, TodoFactory} from './services/TodoStore';
@Component({selector: 'todo-app', viewProviders: [Store, TodoFactory]}) @Component({
@View({templateUrl: 'todo.html', directives: [NgFor, FORM_DIRECTIVES]}) selector: 'todo-app',
viewProviders: [Store, TodoFactory],
templateUrl: 'todo.html',
directives: [NgFor, FORM_DIRECTIVES]
})
export class TodoApp { export class TodoApp {
todoEdit: Todo = null; todoEdit: Todo = null;
inputValue: string; inputValue: string;

View File

@ -1,9 +1,9 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {Zippy} from './zippy'; import {Zippy} from './zippy';
@Component({selector: 'zippy-app'}) @Component({
@View({ selector: 'zippy-app',
template: ` template: `
<zippy (open)="pushLog('open')" (close)="pushLog('close')" title="Details"> <zippy (open)="pushLog('open')" (close)="pushLog('close')" title="Details">
This is some content. This is some content.

View File

@ -546,7 +546,6 @@ const CORE = [
'var Self:SelfFactory', 'var Self:SelfFactory',
'var SkipSelf:SkipSelfFactory', 'var SkipSelf:SkipSelfFactory',
'var Type:any', 'var Type:any',
'var View:ViewFactory',
'var ViewChild:ViewChildFactory', 'var ViewChild:ViewChildFactory',
'var ViewChildren:ViewChildrenFactory', 'var ViewChildren:ViewChildrenFactory',
'var ViewQuery:QueryFactory', 'var ViewQuery:QueryFactory',

View File

@ -1,10 +1,8 @@
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
@Component({ @Component({
selector: 'my-app' selector: 'my-app',
})
@View({
template: '<h1>Hello {{ name }}</h1>' template: '<h1>Hello {{ name }}</h1>'
}) })
// Component controller // Component controller

View File

@ -1,11 +1,9 @@
import {Component, View} from 'angular2/core'; import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'; import {bootstrap} from 'angular2/platform/browser';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router'; import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router';
@Component({ @Component({
selector: 'my-app' selector: 'my-app',
})
@View({
template: '<h1>Hello</h1>', template: '<h1>Hello</h1>',
}) })
class FooCmp { class FooCmp {
@ -14,9 +12,7 @@ class FooCmp {
@Component({ @Component({
selector: 'my-app' selector: 'my-app',
})
@View({
template: '<h1>Hello {{ name }}</h1><router-outlet></router-outlet>', template: '<h1>Hello {{ name }}</h1><router-outlet></router-outlet>',
directives: ROUTER_DIRECTIVES directives: ROUTER_DIRECTIVES
}) })