@@ -112,9 +112,7 @@ Example of a component:
|
||||
'title', | - title mapped to component title
|
||||
'open' | - open attribute mapped to component's open property
|
||||
], |
|
||||
}) |
|
||||
@View({ | View annotation
|
||||
templateUrl: 'pane.html' | - URL of template HTML
|
||||
templateUrl: 'pane.html' | URL of template HTML
|
||||
}) |
|
||||
class Pane { | Component controller class
|
||||
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
|
||||
selector: 'my-app', | configures the services to be injected.
|
||||
viewBindings: [MyService] |
|
||||
}) |
|
||||
@View({ | Assume we have a template that needs to be
|
||||
templateUrl: 'my_app.html', | configured with directives to be injected.
|
||||
directives: [House] |
|
||||
viewBindings: [MyService], |
|
||||
templateUrl: 'my_app.html', | Assume we have a template that needs to be
|
||||
directives: [House] | configured with directives to be injected.
|
||||
}) |
|
||||
class MyApp {} |
|
||||
|
|
||||
@@ -273,8 +269,6 @@ Here is an example of the kinds of injections which can be achieved:
|
||||
```
|
||||
@Component({ |
|
||||
selector: 'my-app' |
|
||||
}) |
|
||||
@View({ |
|
||||
templateUrl: 'my_app.html', |
|
||||
directives: [Form, FieldSet, |
|
||||
Field, Primary] |
|
||||
@@ -329,8 +323,6 @@ Shadow DOM provides an encapsulation for components, so as a general rule it doe
|
||||
```
|
||||
@Component({
|
||||
selector: '[kid]'
|
||||
})
|
||||
@View({
|
||||
templateUrl: 'kid.html',
|
||||
directives: []
|
||||
})
|
||||
@@ -347,8 +339,6 @@ class Kid {
|
||||
|
||||
@Component({
|
||||
selector: '[dad]'
|
||||
})
|
||||
@View({
|
||||
templateUrl: 'dad.html',
|
||||
directives: [Kid]
|
||||
})
|
||||
@@ -361,9 +351,7 @@ class Dad {
|
||||
|
||||
@Component({
|
||||
selector: '[grandpa]',
|
||||
viewBindings: []
|
||||
})
|
||||
@View({
|
||||
viewBindings: [],
|
||||
templateUrl: 'grandpa.html',
|
||||
directives: [Dad]
|
||||
})
|
||||
|
||||
@@ -179,9 +179,7 @@ Both `MyComponent` and `MyDirective` are created on the same element.
|
||||
],
|
||||
viewBindings: [
|
||||
bind('viewService').toValue('View_MyComponentService')
|
||||
]
|
||||
})
|
||||
@View({
|
||||
],
|
||||
template: `<needs-view-service></needs-view-service>`,
|
||||
directives: [NeedsViewService]
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import {CORE_DIRECTIVES} from './directives';
|
||||
* NgModel).
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@ import {NgPlural, NgPluralCase} from './ng_plural';
|
||||
* application.
|
||||
*
|
||||
* 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))
|
||||
*
|
||||
|
||||
@@ -32,8 +32,8 @@ export class SwitchView {
|
||||
* ### Example ([live demo](http://plnkr.co/edit/DQMTII95CbuqWrl3lYAs?p=preview))
|
||||
*
|
||||
* ```typescript
|
||||
* @Component({selector: 'app'})
|
||||
* @View({
|
||||
* @Component({
|
||||
* selector: 'app',
|
||||
* template: `
|
||||
* <p>Value = {{value}}</p>
|
||||
* <button (click)="inc()">Increment</button>
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -33,8 +33,6 @@ const controlGroupProvider =
|
||||
* @Component({
|
||||
* selector: 'my-app',
|
||||
* directives: [FORM_DIRECTIVES],
|
||||
* })
|
||||
* @View({
|
||||
* template: `
|
||||
* <div>
|
||||
* <h2>Angular2 Control & ControlGroup Example</h2>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
* application.
|
||||
*
|
||||
* 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([
|
||||
AsyncPipe,
|
||||
|
||||
@@ -45,7 +45,7 @@ export class ViewResolver {
|
||||
if (isPresent(compMeta)) {
|
||||
if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl) && isBlank(viewMeta)) {
|
||||
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)) {
|
||||
this._throwMixingViewAndComponent("template", component);
|
||||
@@ -84,7 +84,8 @@ export class ViewResolver {
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
return viewMeta;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ export interface ComponentFactory {
|
||||
* import {Component, View} from "angular2/core";
|
||||
*
|
||||
* @Component({...})
|
||||
* @View({...})
|
||||
* class MyComponent {
|
||||
* constructor() {
|
||||
* ...
|
||||
@@ -481,8 +480,7 @@ export interface HostListenerFactory {
|
||||
/**
|
||||
* Declare reusable UI building blocks for an application.
|
||||
*
|
||||
* Each Angular component requires a single `@Component` and at least one `@View` annotation. The
|
||||
* `@Component`
|
||||
* Each Angular component requires a single `@Component` annotation. The `@Component`
|
||||
* annotation specifies when a component is instantiated, and which properties and hostListeners it
|
||||
* binds to.
|
||||
*
|
||||
@@ -493,8 +491,6 @@ export interface HostListenerFactory {
|
||||
*
|
||||
* All template expressions and statements are then evaluated against the component instance.
|
||||
*
|
||||
* For details on the `@View` annotation, see {@link ViewMetadata}.
|
||||
*
|
||||
* ## Lifecycle hooks
|
||||
*
|
||||
* 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 =
|
||||
<ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
|
||||
var View: ViewFactory = <ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
|
||||
|
||||
/**
|
||||
* 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))
|
||||
*
|
||||
* ```javascript
|
||||
* @Component({...})
|
||||
* @View({
|
||||
* @Component({
|
||||
* ...,
|
||||
* template: `
|
||||
* <item> a </item>
|
||||
* <item> b </item>
|
||||
|
||||
@@ -242,8 +242,8 @@ export class ContentChildMetadata extends QueryMetadata {
|
||||
* ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
|
||||
*
|
||||
* ```javascript
|
||||
* @Component({...})
|
||||
* @View({
|
||||
* @Component({
|
||||
* ...,
|
||||
* template: `
|
||||
* <item> a </item>
|
||||
* <item> b </item>
|
||||
|
||||
@@ -59,8 +59,10 @@ export class RouteParams {
|
||||
* ])
|
||||
* class AppCmp {}
|
||||
*
|
||||
* @Component({...})
|
||||
* @View({ template: 'user: {{isAdmin}}' })
|
||||
* @Component({
|
||||
* ...,
|
||||
* template: 'user: {{isAdmin}}'
|
||||
* })
|
||||
* class UserCmp {
|
||||
* string: isAdmin;
|
||||
* constructor(data: RouteData) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
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 {NgClass} from 'angular2/src/common/directives/ng_class';
|
||||
|
||||
@@ -528,8 +528,7 @@ export function main() {
|
||||
})
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgClass, NgFor]})
|
||||
@Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''})
|
||||
class TestComponent {
|
||||
condition: boolean = true;
|
||||
items: any[];
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
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 {NgIf} from 'angular2/src/common/directives/ng_if';
|
||||
import {By} from 'angular2/platform/common_dom';
|
||||
@@ -472,8 +472,7 @@ class Foo {
|
||||
toString() { return 'foo'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgFor, NgIf]})
|
||||
@Component({selector: 'test-cmp', directives: [NgFor, NgIf], template: ''})
|
||||
class TestComponent {
|
||||
@ContentChild(TemplateRef) contentTpl: TemplateRef;
|
||||
items: any;
|
||||
@@ -482,8 +481,7 @@ class TestComponent {
|
||||
trackByIndex(index: number, item: any): number { return index; }
|
||||
}
|
||||
|
||||
@Component({selector: 'outer-cmp'})
|
||||
@View({directives: [TestComponent]})
|
||||
@Component({selector: 'outer-cmp', directives: [TestComponent], template: ''})
|
||||
class ComponentUsingTestComponent {
|
||||
items: any;
|
||||
constructor() { this.items = [1, 2]; }
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
|
||||
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 {IS_DART} from 'angular2/src/facade/lang';
|
||||
@@ -224,8 +224,7 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgIf]})
|
||||
@Component({selector: 'test-cmp', directives: [NgIf], template: ''})
|
||||
class TestComponent {
|
||||
booleanCondition: boolean;
|
||||
nestedBooleanCondition: boolean;
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
xit,
|
||||
} 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';
|
||||
|
||||
export function main() {
|
||||
@@ -128,8 +128,7 @@ export class TestLocalizationMap extends NgLocalization {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgPlural, NgPluralCase]})
|
||||
@Component({selector: 'test-cmp', directives: [NgPlural, NgPluralCase], template: ''})
|
||||
class TestComponent {
|
||||
switchValue: number;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
|
||||
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 {NgStyle} from 'angular2/src/common/directives/ng_style';
|
||||
@@ -137,8 +137,7 @@ export function main() {
|
||||
})
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgStyle]})
|
||||
@Component({selector: 'test-cmp', directives: [NgStyle], template: ''})
|
||||
class TestComponent {
|
||||
expr;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
xit,
|
||||
} 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';
|
||||
|
||||
@@ -145,8 +145,8 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault]})
|
||||
@Component(
|
||||
{selector: 'test-cmp', directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault], template: ''})
|
||||
class TestComponent {
|
||||
switchValue: any;
|
||||
when1: any;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
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';
|
||||
|
||||
export function main() {
|
||||
@@ -65,8 +65,7 @@ class TestDirective {
|
||||
constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); }
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [TestDirective]})
|
||||
@Component({selector: 'test-cmp', directives: [TestDirective], template: ''})
|
||||
class TestComponent {
|
||||
text: string;
|
||||
constructor() { this.text = 'foo'; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Directive, View, Output, EventEmitter} from 'angular2/core';
|
||||
import {Component, Directive, Output, EventEmitter} from 'angular2/core';
|
||||
import {
|
||||
ComponentFixture,
|
||||
afterEach,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
beforeEachProviders
|
||||
} 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 {SpyTemplateCompiler} from './spies';
|
||||
import {TemplateCompiler} from 'angular2/src/compiler/compiler';
|
||||
@@ -52,7 +52,6 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'some-comp'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'some-comp', template: ''})
|
||||
class SomeComponent {
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import {RuntimeMetadataResolver} from 'angular2/src/compiler/runtime_metadata';
|
||||
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces';
|
||||
import {
|
||||
Component,
|
||||
View,
|
||||
Directive,
|
||||
ViewEncapsulation,
|
||||
ChangeDetectionStrategy,
|
||||
@@ -125,9 +124,7 @@ class ComponentWithoutModuleId {
|
||||
},
|
||||
exportAs: 'someExportAs',
|
||||
moduleId: 'someModuleId',
|
||||
changeDetection: ChangeDetectionStrategy.CheckAlways
|
||||
})
|
||||
@View({
|
||||
changeDetection: ChangeDetectionStrategy.CheckAlways,
|
||||
template: 'someTemplate',
|
||||
templateUrl: 'someTemplateUrl',
|
||||
encapsulation: ViewEncapsulation.Emulated,
|
||||
|
||||
@@ -37,7 +37,7 @@ import {AppView, AppProtoView} from 'angular2/src/core/linker/view';
|
||||
import {AppElement} from 'angular2/src/core/linker/element';
|
||||
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 {
|
||||
@@ -338,9 +338,7 @@ export class UpperCasePipe implements PipeTransform {
|
||||
selector: 'comp-a',
|
||||
host: {'[title]': '\'someHostValue\''},
|
||||
moduleId: THIS_MODULE_ID,
|
||||
exportAs: 'someExportAs'
|
||||
})
|
||||
@View({
|
||||
exportAs: 'someExportAs',
|
||||
template: '<a [href]="\'someCtxValue\' | uppercase"></a>',
|
||||
styles: ['div {color: red}'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
@@ -349,8 +347,9 @@ export class UpperCasePipe implements PipeTransform {
|
||||
export class CompWithBindingsAndStylesAndPipes {
|
||||
}
|
||||
|
||||
@Component({selector: 'tree', moduleId: THIS_MODULE_ID})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'tree',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<template><tree></tree></template>',
|
||||
directives: [TreeComp],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
@@ -358,8 +357,9 @@ export class CompWithBindingsAndStylesAndPipes {
|
||||
export class TreeComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'comp-wit-dup-tpl', moduleId: THIS_MODULE_ID})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'comp-wit-dup-tpl',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<tree></tree>',
|
||||
directives: [TreeComp, TreeComp],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
@@ -367,13 +367,18 @@ export class TreeComp {
|
||||
export class CompWithDupDirectives {
|
||||
}
|
||||
|
||||
@Component({selector: 'comp-url', moduleId: THIS_MODULE_ID})
|
||||
@View({templateUrl: 'compUrl.html', encapsulation: ViewEncapsulation.None})
|
||||
@Component({
|
||||
selector: 'comp-url',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
templateUrl: 'compUrl.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class CompWithTemplateUrl {
|
||||
}
|
||||
|
||||
@Component({selector: 'comp-tpl', moduleId: THIS_MODULE_ID})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'comp-tpl',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<template><a [href]="\'someEmbeddedValue\'"></a></template>',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
@@ -382,18 +387,22 @@ export class CompWithEmbeddedTemplate {
|
||||
|
||||
|
||||
@Directive({selector: 'plain'})
|
||||
@View({template: ''})
|
||||
export class NonComponent {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'comp2', moduleId: THIS_MODULE_ID})
|
||||
@View({template: '<b></b>', encapsulation: ViewEncapsulation.None})
|
||||
@Component({
|
||||
selector: 'comp2',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<b></b>',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class Comp2 {
|
||||
}
|
||||
|
||||
@Component({selector: 'comp1', moduleId: THIS_MODULE_ID})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'comp1',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<a></a>, <comp2></comp2>',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
directives: [Comp2]
|
||||
@@ -401,8 +410,9 @@ export class Comp2 {
|
||||
export class Comp1 {
|
||||
}
|
||||
|
||||
@Component({selector: 'comp-with-2nested', moduleId: THIS_MODULE_ID})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'comp-with-2nested',
|
||||
moduleId: THIS_MODULE_ID,
|
||||
template: '<comp1></comp1>, <comp2></comp2>',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
directives: [Comp1, Comp2]
|
||||
|
||||
@@ -22,7 +22,7 @@ import {Injectable} from 'angular2/core';
|
||||
import {NgFor, NgIf} from 'angular2/common';
|
||||
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()
|
||||
class Logger {
|
||||
@@ -43,8 +43,8 @@ class MessageDir {
|
||||
set message(newMessage) { this.logger.add(newMessage); }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'child-comp',
|
||||
template: `<div class="child" message="child">
|
||||
<span class="childnested" message="nestedchild">Child</span>
|
||||
</div>
|
||||
@@ -58,8 +58,9 @@ class ChildComp {
|
||||
constructor() { this.childBinding = 'Original'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'parent-comp', viewProviders: [Logger]})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'parent-comp',
|
||||
viewProviders: [Logger],
|
||||
template: `<div class="parent" message="parent">
|
||||
<span class="parentnested" message="nestedparent">Parent</span>
|
||||
</div>
|
||||
@@ -81,8 +82,8 @@ class CustomEmitter {
|
||||
constructor() { this.myevent = new EventEmitter(); }
|
||||
}
|
||||
|
||||
@Component({selector: 'events-comp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'events-comp',
|
||||
template: `<button (click)="handleClick()"></button>
|
||||
<custom-emitter (myevent)="handleCustom()"></custom-emitter>`,
|
||||
directives: [CustomEmitter],
|
||||
@@ -102,8 +103,9 @@ class EventsComp {
|
||||
handleCustom() { this.customed = true; }
|
||||
}
|
||||
|
||||
@Component({selector: 'cond-content-comp', viewProviders: [Logger]})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'cond-content-comp',
|
||||
viewProviders: [Logger],
|
||||
template: `<div class="child" message="child" *ngIf="myBool"><ng-content></ng-content></div>`,
|
||||
directives: [NgIf, MessageDir],
|
||||
})
|
||||
@@ -112,8 +114,9 @@ class ConditionalContentComp {
|
||||
myBool: boolean = false;
|
||||
}
|
||||
|
||||
@Component({selector: 'conditional-parent-comp', viewProviders: [Logger]})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'conditional-parent-comp',
|
||||
viewProviders: [Logger],
|
||||
template: `<span class="parent" [innerHtml]="parentBinding"></span>
|
||||
<cond-content-comp class="cond-content-comp-class">
|
||||
<span class="from-parent"></span>
|
||||
@@ -126,8 +129,9 @@ class ConditionalParentComp {
|
||||
constructor() { this.parentBinding = 'OriginalParent'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'using-for', viewProviders: [Logger]})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'using-for',
|
||||
viewProviders: [Logger],
|
||||
template: `<span *ngFor="#thing of stuff" [innerHtml]="thing"></span>
|
||||
<ul message="list">
|
||||
<li *ngFor="#item of stuff" [innerHtml]="item"></li>
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
AfterViewInit,
|
||||
AfterViewChecked
|
||||
} 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() {
|
||||
describe('directive lifecycle integration spec', () => {
|
||||
@@ -63,10 +63,14 @@ class LifecycleDir implements DoCheck {
|
||||
ngDoCheck() { this._log.add("child_ngDoCheck"); }
|
||||
}
|
||||
|
||||
@Component({selector: "[lifecycle]", inputs: ['field']})
|
||||
@View({template: `<div lifecycle-dir></div>`, directives: [LifecycleDir]})
|
||||
class LifecycleCmp implements OnChanges, OnInit, DoCheck, AfterContentInit, AfterContentChecked,
|
||||
AfterViewInit, AfterViewChecked {
|
||||
@Component({
|
||||
selector: "[lifecycle]",
|
||||
inputs: ['field'],
|
||||
template: `<div lifecycle-dir></div>`,
|
||||
directives: [LifecycleDir]
|
||||
})
|
||||
class LifecycleCmp implements OnChanges,
|
||||
OnInit, DoCheck, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked {
|
||||
field;
|
||||
constructor(private _log: Log) {}
|
||||
|
||||
@@ -85,7 +89,6 @@ class LifecycleCmp implements OnChanges, OnInit, DoCheck, AfterContentInit, Afte
|
||||
ngAfterViewChecked() { this._log.add("ngAfterViewChecked"); }
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({directives: []})
|
||||
@Component({selector: 'my-comp', directives: []})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ import {
|
||||
Directive,
|
||||
Inject,
|
||||
Query,
|
||||
QueryList,
|
||||
View
|
||||
QueryList
|
||||
} from 'angular2/core';
|
||||
import {NgFor} from 'angular2/common';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
@@ -39,16 +38,17 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'app', viewProviders: [forwardRef(() => Frame)]})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'app',
|
||||
viewProviders: [forwardRef(() => Frame)],
|
||||
template: `<door><lock></lock></door>`,
|
||||
directives: [forwardRef(() => Door), forwardRef(() => Lock)],
|
||||
})
|
||||
class App {
|
||||
}
|
||||
|
||||
@Component({selector: 'lock'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'lock',
|
||||
directives: [NgFor],
|
||||
template: `{{frame.name}}(<span *ngFor="var lock of locks">{{lock.name}}</span>)`,
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import {OnDestroy} from 'angular2/core';
|
||||
import {Injector} from 'angular2/core';
|
||||
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 {ElementRef, ElementRef_} from 'angular2/src/core/linker/element_ref';
|
||||
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
||||
@@ -369,10 +369,7 @@ function createRootElement(doc: any, name: string): any {
|
||||
return rootEl;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'child-cmp',
|
||||
})
|
||||
@View({template: '{{ctxProp}}'})
|
||||
@Component({selector: 'child-cmp', template: '{{ctxProp}}'})
|
||||
class ChildComp {
|
||||
ctxProp: string;
|
||||
constructor() { this.ctxProp = 'hello'; }
|
||||
@@ -381,8 +378,11 @@ class ChildComp {
|
||||
|
||||
class DynamicallyCreatedComponentService {}
|
||||
|
||||
@Component({selector: 'hello-cmp', viewProviders: [DynamicallyCreatedComponentService]})
|
||||
@View({template: "{{greeting}}"})
|
||||
@Component({
|
||||
selector: 'hello-cmp',
|
||||
viewProviders: [DynamicallyCreatedComponentService],
|
||||
template: "{{greeting}}"
|
||||
})
|
||||
class DynamicallyCreatedCmp implements OnDestroy {
|
||||
greeting: string;
|
||||
dynamicallyCreatedComponentService: DynamicallyCreatedComponentService;
|
||||
@@ -396,48 +396,41 @@ class DynamicallyCreatedCmp implements OnDestroy {
|
||||
ngOnDestroy() { this.destroyed = true; }
|
||||
}
|
||||
|
||||
@Component({selector: 'dummy'})
|
||||
@View({template: "DynamicallyLoaded;"})
|
||||
@Component({selector: 'dummy', template: "DynamicallyLoaded;"})
|
||||
class DynamicallyLoaded {
|
||||
}
|
||||
|
||||
@Component({selector: 'dummy'})
|
||||
@View({template: "DynamicallyLoaded;"})
|
||||
@Component({selector: 'dummy', template: "DynamicallyLoaded;"})
|
||||
class DynamicallyLoadedThrows {
|
||||
constructor() { throw new BaseException("ThrownInConstructor"); }
|
||||
}
|
||||
|
||||
@Component({selector: 'dummy'})
|
||||
@View({template: "DynamicallyLoaded2;"})
|
||||
@Component({selector: 'dummy', template: "DynamicallyLoaded2;"})
|
||||
class DynamicallyLoaded2 {
|
||||
}
|
||||
|
||||
@Component({selector: 'dummy', host: {'[id]': 'id'}})
|
||||
@View({template: "DynamicallyLoadedWithHostProps;"})
|
||||
@Component({selector: 'dummy', host: {'[id]': 'id'}, template: "DynamicallyLoadedWithHostProps;"})
|
||||
class DynamicallyLoadedWithHostProps {
|
||||
id: string;
|
||||
|
||||
constructor() { this.id = "default"; }
|
||||
}
|
||||
|
||||
@Component({selector: 'dummy'})
|
||||
@View({template: "dynamic(<ng-content></ng-content>)"})
|
||||
@Component({selector: 'dummy', template: "dynamic(<ng-content></ng-content>)"})
|
||||
class DynamicallyLoadedWithNgContent {
|
||||
id: string;
|
||||
|
||||
constructor() { this.id = "default"; }
|
||||
}
|
||||
|
||||
@Component({selector: 'location'})
|
||||
@View({template: "Location;"})
|
||||
@Component({selector: 'location', template: "Location;"})
|
||||
class Location {
|
||||
elementRef: ElementRef;
|
||||
|
||||
constructor(elementRef: ElementRef) { this.elementRef = elementRef; }
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({directives: []})
|
||||
@Component({selector: 'my-comp', directives: []})
|
||||
class MyComp {
|
||||
ctxBoolProp: boolean;
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ import {
|
||||
import {
|
||||
Directive,
|
||||
Component,
|
||||
View,
|
||||
ViewMetadata,
|
||||
Attribute,
|
||||
Query,
|
||||
@@ -1358,8 +1357,7 @@ function declareTests() {
|
||||
try {
|
||||
tcb.createAsync(ComponentWithoutView);
|
||||
} catch (e) {
|
||||
expect(e.message)
|
||||
.toContain(`must have either 'template', 'templateUrl', or '@View' set.`);
|
||||
expect(e.message).toContain(`must have either 'template' or 'templateUrl' set.`);
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
@@ -1936,8 +1934,7 @@ class MyService {
|
||||
constructor() { this.greeting = 'hello'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'simple-imp-cmp'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'simple-imp-cmp', template: ''})
|
||||
@Injectable()
|
||||
class SimpleImperativeViewComponent {
|
||||
done;
|
||||
@@ -1979,9 +1976,12 @@ class DirectiveWithTitleAndHostProperty {
|
||||
title: string;
|
||||
}
|
||||
|
||||
@Component(
|
||||
{selector: 'push-cmp', inputs: ['prop'], changeDetection: ChangeDetectionStrategy.OnPush})
|
||||
@View({template: '{{field}}'})
|
||||
@Component({
|
||||
selector: 'push-cmp',
|
||||
inputs: ['prop'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: '{{field}}'
|
||||
})
|
||||
@Injectable()
|
||||
class PushCmp {
|
||||
numberOfChecks: number;
|
||||
@@ -1998,9 +1998,9 @@ class PushCmp {
|
||||
@Component({
|
||||
selector: 'push-cmp-with-ref',
|
||||
inputs: ['prop'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: '{{field}}'
|
||||
})
|
||||
@View({template: '{{field}}'})
|
||||
@Injectable()
|
||||
class PushCmpWithRef {
|
||||
numberOfChecks: number;
|
||||
@@ -2055,8 +2055,7 @@ class PushCmpWithAsyncPipe {
|
||||
resolve(value) { this.completer.resolve(value); }
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({directives: []})
|
||||
@Component({selector: 'my-comp', directives: []})
|
||||
@Injectable()
|
||||
class MyComp {
|
||||
ctxProp: string;
|
||||
@@ -2071,8 +2070,13 @@ class MyComp {
|
||||
throwError() { throw 'boom'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-cmp', inputs: ['dirProp'], viewProviders: [MyService]})
|
||||
@View({directives: [MyDir], template: '{{ctxProp}}'})
|
||||
@Component({
|
||||
selector: 'child-cmp',
|
||||
inputs: ['dirProp'],
|
||||
viewProviders: [MyService],
|
||||
directives: [MyDir],
|
||||
template: '{{ctxProp}}'
|
||||
})
|
||||
@Injectable()
|
||||
class ChildComp {
|
||||
ctxProp: string;
|
||||
@@ -2083,15 +2087,13 @@ class ChildComp {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'child-cmp-no-template'})
|
||||
@View({directives: [], template: ''})
|
||||
@Component({selector: 'child-cmp-no-template', directives: [], template: ''})
|
||||
@Injectable()
|
||||
class ChildCompNoTemplate {
|
||||
ctxProp: string = 'hello';
|
||||
}
|
||||
|
||||
@Component({selector: 'child-cmp-svc'})
|
||||
@View({template: '{{ctxProp}}'})
|
||||
@Component({selector: 'child-cmp-svc', template: '{{ctxProp}}'})
|
||||
@Injectable()
|
||||
class ChildCompUsingService {
|
||||
ctxProp: string;
|
||||
@@ -2105,8 +2107,11 @@ class SomeDirective {
|
||||
|
||||
class SomeDirectiveMissingAnnotation {}
|
||||
|
||||
@Component({selector: 'cmp-with-host'})
|
||||
@View({template: '<p>Component with an injected host</p>', directives: [SomeDirective]})
|
||||
@Component({
|
||||
selector: 'cmp-with-host',
|
||||
template: '<p>Component with an injected host</p>',
|
||||
directives: [SomeDirective]
|
||||
})
|
||||
@Injectable()
|
||||
class CompWithHost {
|
||||
myHost: SomeDirective;
|
||||
@@ -2283,8 +2288,8 @@ class ToolbarViewContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'toolbar'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'toolbar',
|
||||
template: 'TOOLBAR(<div *ngFor="var part of query" [toolbarVc]="part"></div>)',
|
||||
directives: [ToolbarViewContainer, NgFor]
|
||||
})
|
||||
@@ -2321,9 +2326,9 @@ function createInjectableWithLogging(inj: Injector) {
|
||||
selector: 'component-providing-logging-injectable',
|
||||
providers: [
|
||||
new Provider(InjectableService, {useFactory: createInjectableWithLogging, deps: [Injector]})
|
||||
]
|
||||
],
|
||||
template: ''
|
||||
})
|
||||
@View({template: ''})
|
||||
@Injectable()
|
||||
class ComponentProvidingLoggingInjectable {
|
||||
created: boolean = false;
|
||||
@@ -2335,8 +2340,11 @@ class ComponentProvidingLoggingInjectable {
|
||||
class DirectiveProvidingInjectable {
|
||||
}
|
||||
|
||||
@Component({selector: 'directive-providing-injectable', viewProviders: [[InjectableService]]})
|
||||
@View({template: ''})
|
||||
@Component({
|
||||
selector: 'directive-providing-injectable',
|
||||
viewProviders: [[InjectableService]],
|
||||
template: ''
|
||||
})
|
||||
@Injectable()
|
||||
class DirectiveProvidingInjectableInView {
|
||||
}
|
||||
@@ -2344,16 +2352,15 @@ class DirectiveProvidingInjectableInView {
|
||||
@Component({
|
||||
selector: 'directive-providing-injectable',
|
||||
providers: [new Provider(InjectableService, {useValue: 'host'})],
|
||||
viewProviders: [new Provider(InjectableService, {useValue: 'view'})]
|
||||
viewProviders: [new Provider(InjectableService, {useValue: 'view'})],
|
||||
template: ''
|
||||
})
|
||||
@View({template: ''})
|
||||
@Injectable()
|
||||
class DirectiveProvidingInjectableInHostAndView {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'directive-consuming-injectable'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'directive-consuming-injectable', template: ''})
|
||||
@Injectable()
|
||||
class DirectiveConsumingInjectable {
|
||||
injectable;
|
||||
@@ -2369,8 +2376,7 @@ class DirectiveContainingDirectiveConsumingAnInjectable {
|
||||
directive;
|
||||
}
|
||||
|
||||
@Component({selector: 'directive-consuming-injectable-unbounded'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'directive-consuming-injectable-unbounded', template: ''})
|
||||
@Injectable()
|
||||
class DirectiveConsumingInjectableUnbounded {
|
||||
injectable;
|
||||
@@ -2413,9 +2419,7 @@ function createParentBus(peb) {
|
||||
providers: [
|
||||
new Provider(EventBus,
|
||||
{useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]})
|
||||
]
|
||||
})
|
||||
@View({
|
||||
],
|
||||
directives: [forwardRef(() => ChildConsumingEventBus)],
|
||||
template: `
|
||||
<child-consuming-event-bus></child-consuming-event-bus>
|
||||
|
||||
@@ -30,7 +30,6 @@ import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
TemplateRef,
|
||||
View,
|
||||
ViewContainerRef,
|
||||
ViewEncapsulation,
|
||||
ViewMetadata
|
||||
@@ -580,26 +579,28 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'main'})
|
||||
@View({template: '', directives: []})
|
||||
@Component({selector: 'main', template: '', directives: []})
|
||||
class MainComp {
|
||||
text: string = '';
|
||||
}
|
||||
|
||||
@Component({selector: 'other'})
|
||||
@View({template: '', directives: []})
|
||||
@Component({selector: 'other', template: '', directives: []})
|
||||
class OtherComp {
|
||||
text: string = '';
|
||||
}
|
||||
|
||||
@Component({selector: 'simple', inputs: ['stringProp']})
|
||||
@View({template: 'SIMPLE(<ng-content></ng-content>)', directives: []})
|
||||
@Component({
|
||||
selector: 'simple',
|
||||
inputs: ['stringProp'],
|
||||
template: 'SIMPLE(<ng-content></ng-content>)',
|
||||
directives: []
|
||||
})
|
||||
class Simple {
|
||||
stringProp: string = '';
|
||||
}
|
||||
|
||||
@Component({selector: 'simple-native1'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'simple-native1',
|
||||
template: 'SIMPLE1(<content></content>)',
|
||||
directives: [],
|
||||
encapsulation: ViewEncapsulation.Native,
|
||||
@@ -608,8 +609,8 @@ class Simple {
|
||||
class SimpleNative1 {
|
||||
}
|
||||
|
||||
@Component({selector: 'simple-native2'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'simple-native2',
|
||||
template: 'SIMPLE2(<content></content>)',
|
||||
directives: [],
|
||||
encapsulation: ViewEncapsulation.Native,
|
||||
@@ -618,13 +619,12 @@ class SimpleNative1 {
|
||||
class SimpleNative2 {
|
||||
}
|
||||
|
||||
@Component({selector: 'empty'})
|
||||
@View({template: '', directives: []})
|
||||
@Component({selector: 'empty', template: '', directives: []})
|
||||
class Empty {
|
||||
}
|
||||
|
||||
@Component({selector: 'multiple-content-tags'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'multiple-content-tags',
|
||||
template: '(<ng-content SELECT=".left"></ng-content>, <ng-content></ng-content>)',
|
||||
directives: []
|
||||
})
|
||||
@@ -645,16 +645,16 @@ class ProjectDirective {
|
||||
hide() { this.vc.clear(); }
|
||||
}
|
||||
|
||||
@Component({selector: 'outer-with-indirect-nested'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'outer-with-indirect-nested',
|
||||
template: 'OUTER(<simple><div><ng-content></ng-content></div></simple>)',
|
||||
directives: [Simple]
|
||||
})
|
||||
class OuterWithIndirectNestedComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'outer'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'outer',
|
||||
template:
|
||||
'OUTER(<inner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></inner>)',
|
||||
directives: [forwardRef(() => InnerComponent)]
|
||||
@@ -662,8 +662,8 @@ class OuterWithIndirectNestedComponent {
|
||||
class OuterComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'inner'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'inner',
|
||||
template:
|
||||
'INNER(<innerinner><ng-content select=".left" class="left"></ng-content><ng-content></ng-content></innerinner>)',
|
||||
directives: [forwardRef(() => InnerInnerComponent)]
|
||||
@@ -671,16 +671,16 @@ class OuterComponent {
|
||||
class InnerComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'innerinner'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'innerinner',
|
||||
template: 'INNERINNER(<ng-content select=".left"></ng-content>,<ng-content></ng-content>)',
|
||||
directives: []
|
||||
})
|
||||
class InnerInnerComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'conditional-content'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'conditional-content',
|
||||
template:
|
||||
'<div>(<div *manual><ng-content select=".left"></ng-content></div>, <ng-content></ng-content>)</div>',
|
||||
directives: [ManualViewportDirective]
|
||||
@@ -688,8 +688,8 @@ class InnerInnerComponent {
|
||||
class ConditionalContentComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'conditional-text'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'conditional-text',
|
||||
template:
|
||||
'MAIN(<template manual>FIRST(<template manual>SECOND(<ng-content></ng-content>)</template>)</template>)',
|
||||
directives: [ManualViewportDirective]
|
||||
@@ -697,16 +697,17 @@ class ConditionalContentComponent {
|
||||
class ConditionalTextComponent {
|
||||
}
|
||||
|
||||
@Component({selector: 'tab'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'tab',
|
||||
template: '<div><div *manual>TAB(<ng-content></ng-content>)</div></div>',
|
||||
directives: [ManualViewportDirective]
|
||||
})
|
||||
class Tab {
|
||||
}
|
||||
|
||||
@Component({selector: 'tree', inputs: ['depth']})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'tree',
|
||||
inputs: ['depth'],
|
||||
template: 'TREE({{depth}}:<tree *manual [depth]="depth+1"></tree>)',
|
||||
directives: [ManualViewportDirective, Tree]
|
||||
})
|
||||
@@ -715,8 +716,7 @@ class Tree {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'cmp-d'})
|
||||
@View({template: `<d>{{tagName}}</d>`})
|
||||
@Component({selector: 'cmp-d', template: `<d>{{tagName}}</d>`})
|
||||
class CmpD {
|
||||
tagName: string;
|
||||
constructor(elementRef: ElementRef) {
|
||||
@@ -725,8 +725,7 @@ class CmpD {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'cmp-c'})
|
||||
@View({template: `<c>{{tagName}}</c>`})
|
||||
@Component({selector: 'cmp-c', template: `<c>{{tagName}}</c>`})
|
||||
class CmpC {
|
||||
tagName: string;
|
||||
constructor(elementRef: ElementRef) {
|
||||
@@ -735,43 +734,37 @@ class CmpC {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'cmp-b'})
|
||||
@View({template: `<ng-content></ng-content><cmp-d></cmp-d>`, directives: [CmpD]})
|
||||
@Component({selector: 'cmp-b', template: `<ng-content></ng-content><cmp-d></cmp-d>`, directives: [CmpD]})
|
||||
class CmpB {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'cmp-a'})
|
||||
@View({template: `<ng-content></ng-content><cmp-c></cmp-c>`, directives: [CmpC]})
|
||||
@Component({selector: 'cmp-a', template: `<ng-content></ng-content><cmp-c></cmp-c>`, directives: [CmpC]})
|
||||
class CmpA {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-b11'})
|
||||
@View({template: `{{'b11'}}`, directives: []})
|
||||
@Component({selector: 'cmp-b11', template: `{{'b11'}}`, directives: []})
|
||||
class CmpB11 {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-b12'})
|
||||
@View({template: `{{'b12'}}`, directives: []})
|
||||
@Component({selector: 'cmp-b12', template: `{{'b12'}}`, directives: []})
|
||||
class CmpB12 {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-b21'})
|
||||
@View({template: `{{'b21'}}`, directives: []})
|
||||
@Component({selector: 'cmp-b21', template: `{{'b21'}}`, directives: []})
|
||||
class CmpB21 {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-b22'})
|
||||
@View({template: `{{'b22'}}`, directives: []})
|
||||
@Component({selector: 'cmp-b22', template: `{{'b22'}}`, directives: []})
|
||||
class CmpB22 {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-a1'})
|
||||
@View({template: `{{'a1'}}<cmp-b11></cmp-b11><cmp-b12></cmp-b12>`, directives: [CmpB11, CmpB12]})
|
||||
@Component(
|
||||
{selector: 'cmp-a1', template: `{{'a1'}}<cmp-b11></cmp-b11><cmp-b12></cmp-b12>`, directives: [CmpB11, CmpB12]})
|
||||
class CmpA1 {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp-a2'})
|
||||
@View({template: `{{'a2'}}<cmp-b21></cmp-b21><cmp-b22></cmp-b22>`, directives: [CmpB21, CmpB22]})
|
||||
@Component(
|
||||
{selector: 'cmp-a2', template: `{{'a2'}}<cmp-b21></cmp-b21><cmp-b22></cmp-b22>`, directives: [CmpB21, CmpB22]})
|
||||
class CmpA2 {
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
TemplateRef,
|
||||
Query,
|
||||
QueryList,
|
||||
View,
|
||||
ViewQuery,
|
||||
ContentChildren,
|
||||
ViewChildren,
|
||||
@@ -693,8 +692,7 @@ class TextDirective {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-content-children'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'needs-content-children', template: ''})
|
||||
class NeedsContentChildren implements AfterContentInit {
|
||||
@ContentChildren(TextDirective) textDirChildren: QueryList<TextDirective>;
|
||||
numberOfChildrenAfterContentInit: number;
|
||||
@@ -702,8 +700,8 @@ class NeedsContentChildren implements AfterContentInit {
|
||||
ngAfterContentInit() { this.numberOfChildrenAfterContentInit = this.textDirChildren.length; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-children'})
|
||||
@View({template: '<div text></div>', directives: [TextDirective]})
|
||||
@Component(
|
||||
{selector: 'needs-view-children', template: '<div text></div>', directives: [TextDirective]})
|
||||
class NeedsViewChildren implements AfterViewInit {
|
||||
@ViewChildren(TextDirective) textDirChildren: QueryList<TextDirective>;
|
||||
numberOfChildrenAfterViewInit: number;
|
||||
@@ -711,8 +709,7 @@ class NeedsViewChildren implements AfterViewInit {
|
||||
ngAfterViewInit() { this.numberOfChildrenAfterViewInit = this.textDirChildren.length; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-content-child'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'needs-content-child', template: ''})
|
||||
class NeedsContentChild implements AfterContentInit, AfterContentChecked {
|
||||
_child: TextDirective;
|
||||
|
||||
@@ -732,8 +729,8 @@ class NeedsContentChild implements AfterContentInit, AfterContentChecked {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-child'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-view-child',
|
||||
template: `
|
||||
<div *ngIf="shouldShow" text="foo"></div>
|
||||
`,
|
||||
@@ -764,8 +761,8 @@ class InertDirective {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-query'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-query',
|
||||
directives: [NgFor, TextDirective],
|
||||
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; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-four-queries'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'needs-four-queries', template: ''})
|
||||
class NeedsFourQueries {
|
||||
@ContentChild(TextDirective) query1: TextDirective;
|
||||
@ContentChild(TextDirective) query2: TextDirective;
|
||||
@@ -784,8 +780,11 @@ class NeedsFourQueries {
|
||||
@ContentChild(TextDirective) query4: TextDirective;
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-query-desc'})
|
||||
@View({directives: [NgFor], template: '<div *ngFor="var dir of query">{{dir.text}}|</div>'})
|
||||
@Component({
|
||||
selector: 'needs-query-desc',
|
||||
directives: [NgFor],
|
||||
template: '<div *ngFor="var dir of query">{{dir.text}}|</div>'
|
||||
})
|
||||
@Injectable()
|
||||
class NeedsQueryDesc {
|
||||
query: QueryList<TextDirective>;
|
||||
@@ -794,8 +793,7 @@ class NeedsQueryDesc {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-query-by-var-binding'})
|
||||
@View({directives: [], template: '<ng-content>'})
|
||||
@Component({selector: 'needs-query-by-var-binding', directives: [], template: '<ng-content>'})
|
||||
@Injectable()
|
||||
class NeedsQueryByLabel {
|
||||
query: QueryList<any>;
|
||||
@@ -804,16 +802,18 @@ class NeedsQueryByLabel {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-query-by-var-binding'})
|
||||
@View({directives: [], template: '<div #textLabel>text</div>'})
|
||||
@Component({
|
||||
selector: 'needs-view-query-by-var-binding',
|
||||
directives: [],
|
||||
template: '<div #textLabel>text</div>'
|
||||
})
|
||||
@Injectable()
|
||||
class NeedsViewQueryByLabel {
|
||||
query: QueryList<any>;
|
||||
constructor(@ViewQuery("textLabel") query: QueryList<any>) { this.query = query; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-query-by-var-bindings'})
|
||||
@View({directives: [], template: '<ng-content>'})
|
||||
@Component({selector: 'needs-query-by-var-bindings', directives: [], template: '<ng-content>'})
|
||||
@Injectable()
|
||||
class NeedsQueryByTwoLabels {
|
||||
query: QueryList<any>;
|
||||
@@ -822,8 +822,8 @@ class NeedsQueryByTwoLabels {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-query-and-project'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-query-and-project',
|
||||
directives: [NgFor],
|
||||
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; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-query'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-view-query',
|
||||
directives: [TextDirective],
|
||||
template: '<div text="1"><div text="2"></div></div>' +
|
||||
'<div text="3"></div><div text="4"></div>'
|
||||
@@ -845,8 +845,11 @@ class NeedsViewQuery {
|
||||
constructor(@ViewQuery(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-query-if'})
|
||||
@View({directives: [NgIf, TextDirective], template: '<div *ngIf="show" text="1"></div>'})
|
||||
@Component({
|
||||
selector: 'needs-view-query-if',
|
||||
directives: [NgIf, TextDirective],
|
||||
template: '<div *ngIf="show" text="1"></div>'
|
||||
})
|
||||
@Injectable()
|
||||
class NeedsViewQueryIf {
|
||||
show: boolean;
|
||||
@@ -858,8 +861,8 @@ class NeedsViewQueryIf {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'needs-view-query-nested-if'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-view-query-nested-if',
|
||||
directives: [NgIf, InertDirective, TextDirective],
|
||||
template: '<div text="1"><div *ngIf="show"><div dir></div></div></div>'
|
||||
})
|
||||
@@ -873,8 +876,8 @@ class NeedsViewQueryNestedIf {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-query-order'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-view-query-order',
|
||||
directives: [NgFor, TextDirective, InertDirective],
|
||||
template: '<div text="1"></div>' +
|
||||
'<div *ngFor="var i of list" [text]="i"></div>' +
|
||||
@@ -890,8 +893,8 @@ class NeedsViewQueryOrder {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-view-query-order-with-p'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'needs-view-query-order-with-p',
|
||||
directives: [NgFor, TextDirective, InertDirective],
|
||||
template: '<div dir><div text="1"></div>' +
|
||||
'<div *ngFor="var i of list" [text]="i"></div>' +
|
||||
@@ -907,8 +910,7 @@ class NeedsViewQueryOrderWithParent {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'needs-tpl'})
|
||||
@View({template: '<template var-x="shadow"></template>'})
|
||||
@Component({selector: 'needs-tpl', template: '<template var-x="shadow"></template>'})
|
||||
class NeedsTpl {
|
||||
viewQuery: QueryList<TemplateRef>;
|
||||
query: QueryList<TemplateRef>;
|
||||
@@ -919,8 +921,8 @@ class NeedsTpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
directives: [
|
||||
NeedsQuery,
|
||||
NeedsQueryDesc,
|
||||
@@ -943,7 +945,8 @@ class NeedsTpl {
|
||||
NgIf,
|
||||
NgFor,
|
||||
NeedsFourQueries
|
||||
]
|
||||
],
|
||||
template: ''
|
||||
})
|
||||
@Injectable()
|
||||
class MyComp {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/testing_internal';
|
||||
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 SomePipe {}
|
||||
|
||||
@Component({selector: 'sample'})
|
||||
@View(
|
||||
{template: "some template", directives: [SomeDir], pipes: [SomePipe], styles: ["some styles"]})
|
||||
@Component({
|
||||
selector: 'sample',
|
||||
template: "some template",
|
||||
directives: [SomeDir],
|
||||
pipes: [SomePipe],
|
||||
styles: ["some styles"]
|
||||
})
|
||||
class ComponentWithView {
|
||||
}
|
||||
|
||||
@@ -22,12 +26,10 @@ class ComponentWithTemplate {
|
||||
}
|
||||
|
||||
@Component({selector: 'sample', template: "some template"})
|
||||
@View({template: "some template"})
|
||||
class ComponentWithViewTemplate {
|
||||
}
|
||||
|
||||
@Component({selector: 'sample', templateUrl: "some template url"})
|
||||
@View({template: "some template"})
|
||||
@Component({selector: 'sample', templateUrl: "some template url", template: "some template"})
|
||||
class ComponentWithViewTemplateUrl {
|
||||
}
|
||||
|
||||
@@ -35,9 +37,6 @@ class ComponentWithViewTemplateUrl {
|
||||
class ComponentWithoutView {
|
||||
}
|
||||
|
||||
@View({template: "some template"})
|
||||
class ClassWithView {
|
||||
}
|
||||
|
||||
class SimpleClass {}
|
||||
|
||||
@@ -47,17 +46,6 @@ export function main() {
|
||||
|
||||
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', () => {
|
||||
var viewMetadata = resolver.resolve(ComponentWithTemplate);
|
||||
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', () => {
|
||||
expect(() => resolver.resolve(ComponentWithoutView))
|
||||
.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', () => {
|
||||
expect(() => resolver.resolve(SimpleClass))
|
||||
.toThrowErrorWith("No View decorator found on component 'SimpleClass'");
|
||||
.toThrowErrorWith("Could not compile 'SimpleClass' because it is not a component.");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
xit,
|
||||
} 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';
|
||||
|
||||
export function main() {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {stringify} from 'angular2/src/facade/lang';
|
||||
|
||||
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';
|
||||
|
||||
@@ -108,8 +108,8 @@ export function main() {
|
||||
|
||||
class SomeDirective {}
|
||||
|
||||
@Component({selector: 'cmp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'cmp',
|
||||
template: 'template',
|
||||
directives: [SomeDirective],
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
|
||||
import {bootstrap} from 'angular2/platform/browser';
|
||||
import {ApplicationRef} from 'angular2/src/core/application_ref';
|
||||
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 {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
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 {ComponentRef_, ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@View({template: '{{greeting}} world!'})
|
||||
@Component({selector: 'hello-app', template: '{{greeting}} world!'})
|
||||
class HelloRootCmp {
|
||||
greeting: string;
|
||||
constructor() { this.greeting = 'hello'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@View({template: 'before: <ng-content></ng-content> after: done'})
|
||||
@Component({selector: 'hello-app', template: 'before: <ng-content></ng-content> after: done'})
|
||||
class HelloRootCmpContent {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app-2'})
|
||||
@View({template: '{{greeting}} world, again!'})
|
||||
@Component({selector: 'hello-app-2', template: '{{greeting}} world, again!'})
|
||||
class HelloRootCmp2 {
|
||||
greeting: string;
|
||||
constructor() { this.greeting = 'hello'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
class HelloRootCmp3 {
|
||||
appBinding;
|
||||
|
||||
constructor(@Inject("appBinding") appBinding) { this.appBinding = appBinding; }
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
class HelloRootCmp4 {
|
||||
appRef;
|
||||
|
||||
@@ -71,8 +66,7 @@ class HelloRootMissingTemplate {
|
||||
class HelloRootDirectiveIsNotCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@View({template: ''})
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
class HelloOnDestroyTickCmp implements OnDestroy {
|
||||
appRef: ApplicationRef;
|
||||
constructor(@Inject(ApplicationRef) appRef) { this.appRef = appRef; }
|
||||
|
||||
@@ -222,7 +222,16 @@ var NG_CORE = [
|
||||
'setTestabilityGetter',
|
||||
'Type',
|
||||
'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',
|
||||
'ViewChildMetadata',
|
||||
'ViewChildren',
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
|
||||
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 {
|
||||
@@ -102,15 +102,14 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'user-cmp'})
|
||||
@View({template: "hello {{user}}"})
|
||||
@Component({selector: 'user-cmp', template: "hello {{user}}"})
|
||||
class UserCmp {
|
||||
user: string;
|
||||
constructor(params: RouteParams) { this.user = params.get('name'); }
|
||||
}
|
||||
|
||||
@Component({selector: 'test-component'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'test-component',
|
||||
template: `
|
||||
<div>
|
||||
<a [routerLink]="['/Detail']"
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
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 {Console} from 'angular2/src/core/console';
|
||||
import {provide, ViewChild, AfterViewInit} from 'angular2/core';
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
xit
|
||||
} 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 {
|
||||
PromiseWrapper,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
xit
|
||||
} 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 {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router';
|
||||
|
||||
@@ -22,7 +22,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
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 {
|
||||
@@ -69,10 +69,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
function compile(template: string = "<router-outlet></router-outlet>") {
|
||||
return tcb.overrideView(MyComp, new View({
|
||||
template: ('<div>' + template + '</div>'),
|
||||
directives: [RouterOutlet, RouterLink]
|
||||
}))
|
||||
return tcb.overrideTemplate(MyComp, ('<div>' + template + '</div>'))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => { fixture = tc; });
|
||||
}
|
||||
@@ -382,7 +379,7 @@ function getHref(tc: ComponentFixture) {
|
||||
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 {
|
||||
name;
|
||||
}
|
||||
|
||||
@@ -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 {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
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 {Console} from 'angular2/src/core/console';
|
||||
import {provide} from 'angular2/core';
|
||||
@@ -213,13 +213,15 @@ export function main() {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'hello-cmp'})
|
||||
@View({template: 'hello'})
|
||||
@Component({selector: 'hello-cmp', template: 'hello'})
|
||||
class HelloCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/before', redirectTo: ['Hello']},
|
||||
{path: '/after', component: HelloCmp, name: 'Hello'}
|
||||
@@ -232,8 +234,11 @@ function HelloLoader(): Promise<any> {
|
||||
return Promise.resolve(HelloCmp);
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'loader', loader: HelloLoader}},
|
||||
])
|
||||
@@ -241,8 +246,11 @@ class AsyncAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/hello', loader: HelloLoader},
|
||||
])
|
||||
@@ -250,15 +258,21 @@ class ConciseAsyncAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> } aside { <router-outlet name="aside"></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
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}])
|
||||
class AuxAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'constructor', constructor: HelloCmp}},
|
||||
])
|
||||
@@ -266,45 +280,66 @@ class ExplicitConstructorAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'parent-cmp'})
|
||||
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'parent-cmp',
|
||||
template: `parent { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/child', component: HelloCmp}])
|
||||
class ParentCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/parent/...', component: ParentCmp}])
|
||||
class HierarchyAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/hello'}])
|
||||
class WrongConfigCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/child', component: HelloCmp, name: 'child'}])
|
||||
class BadAliasNameCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/child', component: HelloCmp, as: 'child'}])
|
||||
class BadAliasCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([{path: '/child', component: HelloCmp, as: 'Child', name: 'Child'}])
|
||||
class MultipleAliasCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@Component({
|
||||
selector: 'app-cmp',
|
||||
template: `root { <router-outlet></router-outlet> }`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}},
|
||||
])
|
||||
|
||||
@@ -16,43 +16,47 @@ import {
|
||||
|
||||
import {Injectable, provide} from 'angular2/core';
|
||||
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'})
|
||||
@View({template: `<span>Original {{childBinding}}</span>`, directives: []})
|
||||
@Component(
|
||||
{selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`, directives: []})
|
||||
@Injectable()
|
||||
class ChildComp {
|
||||
childBinding: string;
|
||||
constructor() { this.childBinding = 'Child'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({template: `<span>Mock</span>`})
|
||||
@Component({selector: 'child-comp', template: `<span>Mock</span>`})
|
||||
@Injectable()
|
||||
class MockChildComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'parent-comp'})
|
||||
@View({template: `Parent(<child-comp></child-comp>)`, directives: [ChildComp]})
|
||||
@Component({
|
||||
selector: 'parent-comp',
|
||||
template: `Parent(<child-comp></child-comp>)`,
|
||||
directives: [ChildComp]
|
||||
})
|
||||
@Injectable()
|
||||
class ParentComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'my-if-comp'})
|
||||
@View({template: `MyIf(<span *ngIf="showMore">More</span>)`, directives: [NgIf]})
|
||||
@Component({
|
||||
selector: 'my-if-comp',
|
||||
template: `MyIf(<span *ngIf="showMore">More</span>)`,
|
||||
directives: [NgIf]
|
||||
})
|
||||
@Injectable()
|
||||
class MyIfComp {
|
||||
showMore: boolean = false;
|
||||
}
|
||||
|
||||
@Component({selector: 'child-child-comp'})
|
||||
@View({template: `<span>ChildChild</span>`})
|
||||
@Component({selector: 'child-child-comp', template: `<span>ChildChild</span>`})
|
||||
@Injectable()
|
||||
class ChildChildComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'child-comp',
|
||||
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
|
||||
directives: [ChildChildComp]
|
||||
})
|
||||
@@ -62,8 +66,7 @@ class ChildWithChildComp {
|
||||
constructor() { this.childBinding = 'Child'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-child-comp'})
|
||||
@View({template: `<span>ChildChild Mock</span>`})
|
||||
@Component({selector: 'child-child-comp', template: `<span>ChildChild Mock</span>`})
|
||||
@Injectable()
|
||||
class MockChildChildComp {
|
||||
}
|
||||
@@ -78,14 +81,20 @@ class MockFancyService extends FancyService {
|
||||
value: string = 'mocked out value';
|
||||
}
|
||||
|
||||
@Component({selector: 'my-service-comp', bindings: [FancyService]})
|
||||
@View({template: `injected value: {{fancyService.value}}`})
|
||||
@Component({
|
||||
selector: 'my-service-comp',
|
||||
bindings: [FancyService],
|
||||
template: `injected value: {{fancyService.value}}`
|
||||
})
|
||||
class TestBindingsComp {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'my-service-comp', viewProviders: [FancyService]})
|
||||
@View({template: `injected value: {{fancyService.value}}`})
|
||||
@Component({
|
||||
selector: 'my-service-comp',
|
||||
viewProviders: [FancyService],
|
||||
template: `injected value: {{fancyService.value}}`
|
||||
})
|
||||
class TestViewBindingsComp {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@@ -18,48 +18,52 @@ import {
|
||||
|
||||
import {Injectable, bind} from 'angular2/core';
|
||||
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 {XHR} from 'angular2/src/compiler/xhr';
|
||||
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
|
||||
|
||||
// Services, and components for the tests.
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({template: `<span>Original {{childBinding}}</span>`, directives: []})
|
||||
@Component(
|
||||
{selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`, directives: []})
|
||||
@Injectable()
|
||||
class ChildComp {
|
||||
childBinding: string;
|
||||
constructor() { this.childBinding = 'Child'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({template: `<span>Mock</span>`})
|
||||
@Component({selector: 'child-comp', template: `<span>Mock</span>`})
|
||||
@Injectable()
|
||||
class MockChildComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'parent-comp'})
|
||||
@View({template: `Parent(<child-comp></child-comp>)`, directives: [ChildComp]})
|
||||
@Component({
|
||||
selector: 'parent-comp',
|
||||
template: `Parent(<child-comp></child-comp>)`,
|
||||
directives: [ChildComp]
|
||||
})
|
||||
@Injectable()
|
||||
class ParentComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'my-if-comp'})
|
||||
@View({template: `MyIf(<span *ngIf="showMore">More</span>)`, directives: [NgIf]})
|
||||
@Component({
|
||||
selector: 'my-if-comp',
|
||||
template: `MyIf(<span *ngIf="showMore">More</span>)`,
|
||||
directives: [NgIf]
|
||||
})
|
||||
@Injectable()
|
||||
class MyIfComp {
|
||||
showMore: boolean = false;
|
||||
}
|
||||
|
||||
@Component({selector: 'child-child-comp'})
|
||||
@View({template: `<span>ChildChild</span>`})
|
||||
@Component({selector: 'child-child-comp', template: `<span>ChildChild</span>`})
|
||||
@Injectable()
|
||||
class ChildChildComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'child-comp'})
|
||||
@View({
|
||||
@Component({
|
||||
selector: 'child-comp',
|
||||
template: `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>`,
|
||||
directives: [ChildChildComp]
|
||||
})
|
||||
@@ -69,8 +73,7 @@ class ChildWithChildComp {
|
||||
constructor() { this.childBinding = 'Child'; }
|
||||
}
|
||||
|
||||
@Component({selector: 'child-child-comp'})
|
||||
@View({template: `<span>ChildChild Mock</span>`})
|
||||
@Component({selector: 'child-child-comp', template: `<span>ChildChild Mock</span>`})
|
||||
@Injectable()
|
||||
class MockChildChildComp {
|
||||
}
|
||||
@@ -84,25 +87,32 @@ class MockFancyService extends FancyService {
|
||||
value: string = 'mocked out value';
|
||||
}
|
||||
|
||||
@Component({selector: 'my-service-comp', providers: [FancyService]})
|
||||
@View({template: `injected value: {{fancyService.value}}`})
|
||||
@Component({
|
||||
selector: 'my-service-comp',
|
||||
providers: [FancyService],
|
||||
template: `injected value: {{fancyService.value}}`
|
||||
})
|
||||
class TestProvidersComp {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'my-service-comp', viewProviders: [FancyService]})
|
||||
@View({template: `injected value: {{fancyService.value}}`})
|
||||
@Component({
|
||||
selector: 'my-service-comp',
|
||||
viewProviders: [FancyService],
|
||||
template: `injected value: {{fancyService.value}}`
|
||||
})
|
||||
class TestViewProvidersComp {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'external-template-comp'})
|
||||
@View({templateUrl: '/base/modules/angular2/test/testing/static_assets/test.html'})
|
||||
@Component({
|
||||
selector: 'external-template-comp',
|
||||
templateUrl: '/base/modules/angular2/test/testing/static_assets/test.html'
|
||||
})
|
||||
class ExternalTemplateComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'bad-template-comp'})
|
||||
@View({templateUrl: 'non-existant.html'})
|
||||
@Component({selector: 'bad-template-comp', templateUrl: 'non-existant.html'})
|
||||
class BadTemplateUrl {
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
xit,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {Component, View} from 'angular2/core';
|
||||
import {Component} from 'angular2/core';
|
||||
import {getComponentInfo, parseFields} from 'angular2/src/upgrade/metadata';
|
||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
|
||||
@@ -67,13 +67,11 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'element-name-dashed'})
|
||||
@View({template: ``})
|
||||
@Component({selector: 'element-name-dashed', template: ``})
|
||||
class ElementNameComponent {
|
||||
}
|
||||
|
||||
@Component({selector: '[attr-name]'})
|
||||
@View({template: ``})
|
||||
@Component({selector: '[attr-name]', template: ``})
|
||||
class AttributeNameComponent {
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
Injector,
|
||||
ViewMetadata,
|
||||
Component,
|
||||
View,
|
||||
Injectable,
|
||||
ElementRef
|
||||
} from 'angular2/core';
|
||||
@@ -257,8 +256,7 @@ export function main() {
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({directives: []})
|
||||
@Component({selector: 'my-comp', directives: []})
|
||||
@Injectable()
|
||||
class MyComp {
|
||||
ctxProp: string;
|
||||
|
||||
Reference in New Issue
Block a user