Hello Angular 2.0 (Reflection)
+ Hello Angular 2.0
Loading...
diff --git a/modules/examples/src/hello_world/index.js b/modules/examples/src/hello_world/index.js
index c00cb67d87..c7802178f9 100644
--- a/modules/examples/src/hello_world/index.js
+++ b/modules/examples/src/hello_world/index.js
@@ -1,14 +1,24 @@
-import * as app from './index_common';
+import {HelloCmp} from './index_common';
+import {bootstrap} from 'angular2/angular2';
import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
export function main() {
- // Initializing the reflector is only required for the Dart version of the application.
- // When using Dart, the reflection information is not embedded by default in the source code
- // to keep the size of the generated file small. Importing ReflectionCapabilities and initializing
- // the reflector is required to use the reflection information from Dart mirrors.
- // Dart mirrors are not intended to be use in production code where the transformers generate a
- // more optimal static configuration, see index_static.js for an example.
+ // For Dart users: Initializing the reflector is only required for the Dart version of the
+ // application. When using Dart, the reflection information is not embedded by default in the
+ // source code to keep the size of the generated file small. Importing ReflectionCapabilities and
+ // initializing the reflector is required to use the reflection information from Dart mirrors.
+ // Dart mirrors are not intended to be use in production code.
+ // Angular 2 provides a transformer which generates static code rather than rely on reflection.
+ // For an example, run `pub serve` on the Dart application and inspect this file in your browser.
reflector.reflectionCapabilities = new ReflectionCapabilities();
- app.main();
+
+ // Bootstrapping only requires specifying a root component.
+ // The boundary between the Angular application and the rest of the page is
+ // the shadowDom of this root component.
+ // The selector of the component passed in is used to find where to insert the
+ // application.
+ // You can use the light dom of the tag as temporary content (for
+ // example 'Loading...') before the application is ready.
+ bootstrap(HelloCmp);
}
diff --git a/modules/examples/src/hello_world/index_common.js b/modules/examples/src/hello_world/index_common.js
index bdf9cfb3cc..168aaa6442 100644
--- a/modules/examples/src/hello_world/index_common.js
+++ b/modules/examples/src/hello_world/index_common.js
@@ -1,4 +1,4 @@
-import {bootstrap, Component, Decorator, View, NgElement} from 'angular2/angular2';
+import {Component, Decorator, View, NgElement} from 'angular2/angular2';
import {Injectable} from 'angular2/di';
// Angular 2.0 supports 3 basic types of directives:
@@ -30,7 +30,7 @@ import {Injectable} from 'angular2/di';
// misspelled).
directives: [RedDec]
})
-class HelloCmp {
+export class HelloCmp {
greeting: string;
constructor(service: GreetingService) {
this.greeting = service.greeting;
@@ -61,14 +61,3 @@ class GreetingService {
this.greeting = 'hello';
}
}
-
-export function main() {
- // Bootstrapping only requires specifying a root component.
- // The boundary between the Angular application and the rest of the page is
- // the shadowDom of this root component.
- // The selector of the component passed in is used to find where to insert the
- // application.
- // You can use the light dom of the tag as temporary content (for
- // example 'Loading...') before the application is ready.
- bootstrap(HelloCmp);
-}
diff --git a/modules/examples/src/hello_world/index_static.html b/modules/examples/src/hello_world/index_dynamic.html
similarity index 68%
rename from modules/examples/src/hello_world/index_static.html
rename to modules/examples/src/hello_world/index_dynamic.html
index f6f1b5bb40..16b869170d 100644
--- a/modules/examples/src/hello_world/index_static.html
+++ b/modules/examples/src/hello_world/index_dynamic.html
@@ -1,6 +1,6 @@
- Hello Angular 2.0 (Static)
+ Hello Angular 2.0 (Reflection)
Loading...
diff --git a/modules/examples/src/hello_world/index_dynamic.js b/modules/examples/src/hello_world/index_dynamic.js
new file mode 100644
index 0000000000..fcc9b7120c
--- /dev/null
+++ b/modules/examples/src/hello_world/index_dynamic.js
@@ -0,0 +1,11 @@
+import {HelloCmp} from './index_common';
+import {bootstrap} from 'angular2/angular2';
+import {reflector} from 'angular2/src/reflection/reflection';
+import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
+
+export function main() {
+ // This entry point is not transformed and exists for testing purposes.
+ // See index.js for an explanation.
+ reflector.reflectionCapabilities = new ReflectionCapabilities();
+ bootstrap(HelloCmp);
+}
diff --git a/modules/examples/src/hello_world/index_static.js b/modules/examples/src/hello_world/index_static.js
deleted file mode 100644
index c3c9d32210..0000000000
--- a/modules/examples/src/hello_world/index_static.js
+++ /dev/null
@@ -1,306 +0,0 @@
-import * as app from './index_common';
-
-import {Component, Decorator, View, NgElement} from 'angular2/angular2';
-import {Lexer, Parser, ChangeDetection, ChangeDetector, PipeRegistry, DynamicChangeDetection} from 'angular2/change_detection';
-import {ExceptionHandler} from 'angular2/src/core/exception_handler';
-import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
-
-import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
-import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
-import {ShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/shadow_dom_strategy';
-import {NativeShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/native_shadow_dom_strategy';
-import {EmulatedUnscopedShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy';
-import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
-import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
-import {XHR} from 'angular2/src/services/xhr';
-import {XHRImpl} from 'angular2/src/services/xhr_impl';
-import {UrlResolver} from 'angular2/src/services/url_resolver';
-import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
-import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper';
-import {StyleInliner} from 'angular2/src/render/dom/shadow_dom/style_inliner';
-import {EventManager} from 'angular2/src/render/dom/events/event_manager';
-import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
-import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
-
-import {reflector} from 'angular2/src/reflection/reflection';
-
-import {ViewFactory, VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_factory';
-import {AppViewHydrator} from 'angular2/src/core/compiler/view_hydrator';
-import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
-import {Renderer} from 'angular2/src/render/api';
-import {DirectDomRenderer} from 'angular2/src/render/dom/direct_dom_renderer';
-import * as rc from 'angular2/src/render/dom/compiler/compiler';
-import * as rvf from 'angular2/src/render/dom/view/view_factory';
-import * as rvh from 'angular2/src/render/dom/view/view_hydrator';
-import {Inject} from 'angular2/di';
-
-function setup() {
- reflector.registerType(app.HelloCmp, {
- "factory": (service) => new app.HelloCmp(service),
- "parameters": [[app.GreetingService]],
- "annotations" : [
- new Component({
- selector: 'hello-app',
- injectables: [app.GreetingService]
- }),
- new View({
- directives: [app.RedDec],
- template: `