Skip to content

Commit

Permalink
chore(core): remove @view annotation
Browse files Browse the repository at this point in the history
Closes #7495
  • Loading branch information
btford committed Mar 14, 2016
1 parent 095db67 commit f9fb72f
Show file tree
Hide file tree
Showing 85 changed files with 588 additions and 599 deletions.
2 changes: 1 addition & 1 deletion TOOLS_JS.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ speed things up is to use plain class fields in your expressions and avoid any
kinds of computation. Example:

```typescript
@View({
@Component({
template: '<button [enabled]="isEnabled">{{title}}</button>'
})
class FancyButton {
Expand Down
22 changes: 5 additions & 17 deletions modules/angular2/docs/core/02_directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {} |
|
Expand Down Expand Up @@ -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] |
Expand Down Expand Up @@ -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: []
})
Expand All @@ -347,8 +339,6 @@ class Kid {
@Component({
selector: '[dad]'
})
@View({
templateUrl: 'dad.html',
directives: [Kid]
})
Expand All @@ -361,9 +351,7 @@ class Dad {
@Component({
selector: '[grandpa]',
viewBindings: []
})
@View({
viewBindings: [],
templateUrl: 'grandpa.html',
directives: [Dad]
})
Expand Down
4 changes: 1 addition & 3 deletions modules/angular2/docs/di/di_advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/common/common_directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/common/directives/core_directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
*
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/common/directives/ng_switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/common/forms/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const controlGroupProvider =
* @Component({
* selector: 'my-app',
* directives: [FORM_DIRECTIVES],
* })
* @View({
* template: `
* <div>
* <h2>Angular2 Control &amp; ControlGroup Example</h2>
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/common/pipes/common_pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions modules/angular2/src/core/linker/view_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 4 additions & 9 deletions modules/angular2/src/core/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ export interface ComponentFactory {
* import {Component, View} from "angular2/core";
*
* @Component({...})
* @View({...})
* class MyComponent {
* constructor() {
* ...
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/core/metadata/di.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 4 additions & 2 deletions modules/angular2/src/router/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/common/directives/ng_class_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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[];
Expand Down
8 changes: 3 additions & 5 deletions modules/angular2/test/common/directives/ng_for_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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]; }
Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/common/directives/ng_if_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/common/directives/ng_plural_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/common/directives/ng_style_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -137,8 +137,7 @@ export function main() {
})
}

@Component({selector: 'test-cmp'})
@View({directives: [NgStyle]})
@Component({selector: 'test-cmp', directives: [NgStyle], template: ''})
class TestComponent {
expr;
}
6 changes: 3 additions & 3 deletions modules/angular2/test/common/directives/ng_switch_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/common/directives/non_bindable_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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'; }
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/test/common/forms/integration_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Directive, View, Output, EventEmitter} from 'angular2/core';
import {Component, Directive, Output, EventEmitter} from 'angular2/core';
import {
ComponentFixture,
afterEach,
Expand Down
5 changes: 2 additions & 3 deletions modules/angular2/test/compiler/runtime_compiler_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -52,7 +52,6 @@ export function main() {
});
}

@Component({selector: 'some-comp'})
@View({template: ''})
@Component({selector: 'some-comp', template: ''})
class SomeComponent {
}
Loading

0 comments on commit f9fb72f

Please sign in to comment.