@@ -24,8 +24,7 @@ import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mappe
2424import { UrlResolver } from 'angular2/src/services/url_resolver' ;
2525import { StyleUrlResolver } from 'angular2/src/render/dom/shadow_dom/style_url_resolver' ;
2626import { StyleInliner } from 'angular2/src/render/dom/shadow_dom/style_inliner' ;
27- import { Component } from 'angular2/src/core/annotations/annotations' ;
28- import { PrivateComponentLoader } from 'angular2/src/core/compiler/private_component_loader' ;
27+ import { DynamicComponentLoader } from 'angular2/src/core/compiler/dynamic_component_loader' ;
2928import { TestabilityRegistry , Testability } from 'angular2/src/core/testability/testability' ;
3029import { ViewFactory , VIEW_POOL_CAPACITY } from 'angular2/src/core/compiler/view_factory' ;
3130import { ProtoViewFactory } from 'angular2/src/core/compiler/proto_view_factory' ;
@@ -35,7 +34,7 @@ import * as rc from 'angular2/src/render/dom/compiler/compiler';
3534import * as rvf from 'angular2/src/render/dom/view/view_factory' ;
3635
3736import {
38- appViewToken ,
37+ appComponentRefToken ,
3938 appChangeDetectorToken ,
4039 appElementToken ,
4140 appComponentAnnotatedTypeToken ,
@@ -66,37 +65,20 @@ function _injectorBindings(appComponentType): List<Binding> {
6665 }
6766 return element ;
6867 } , [ appComponentAnnotatedTypeToken , appDocumentToken ] ) ,
69- bind ( appViewToken ) . toAsyncFactory ( ( changeDetection , compiler , injector , appElement ,
70- appComponentAnnotatedType , testability , registry , viewFactory ) => {
68+ bind ( appComponentRefToken ) . toAsyncFactory ( ( dynamicComponentLoader , injector , appElement ,
69+ appComponentAnnotatedType , testability , registry ) => {
7170
7271 // We need to do this here to ensure that we create Testability and
7372 // it's ready on the window for users.
7473 registry . registerApplication ( appElement , testability ) ;
75- var annotation = appComponentAnnotatedType . annotation ;
76- if ( ! isBlank ( annotation ) && ! ( annotation instanceof Component ) ) {
77- var type = appComponentAnnotatedType . type ;
78- throw new BaseException ( `Only Components can be bootstrapped; ` +
79- `Directive of ${ stringify ( type ) } is not a Component` ) ;
80- }
81- return compiler . compileRoot (
82- appElement ,
83- appComponentAnnotatedType . type
84- ) . then (
85- ( appProtoView ) => {
86- // The light Dom of the app element is not considered part of
87- // the angular application. Thus the context and lightDomInjector are
88- // empty.
89- var view = viewFactory . getView ( appProtoView ) ;
90- view . hydrate ( injector , null , new Object ( ) , null ) ;
91- return view ;
92- } ) ;
93- } , [ ChangeDetection , Compiler , Injector , appElementToken , appComponentAnnotatedTypeToken ,
94- Testability , TestabilityRegistry , ViewFactory ] ) ,
74+ return dynamicComponentLoader . loadIntoNewLocation ( appElement , appComponentAnnotatedType . type , null , injector ) ;
75+ } , [ DynamicComponentLoader , Injector , appElementToken , appComponentAnnotatedTypeToken ,
76+ Testability , TestabilityRegistry ] ) ,
9577
96- bind ( appChangeDetectorToken ) . toFactory ( ( rootView ) => rootView . changeDetector ,
97- [ appViewToken ] ) ,
98- bind ( appComponentType ) . toFactory ( ( rootView ) => rootView . elementInjectors [ 0 ] . getComponent ( ) ,
99- [ appViewToken ] ) ,
78+ bind ( appChangeDetectorToken ) . toFactory ( ( ref ) => ref . hostView . changeDetector ,
79+ [ appComponentRefToken ] ) ,
80+ bind ( appComponentType ) . toFactory ( ( ref ) => ref . instance ,
81+ [ appComponentRefToken ] ) ,
10082 bind ( LifeCycle ) . toFactory ( ( exceptionHandler ) => new LifeCycle ( exceptionHandler , null , assertionsEnabled ( ) ) , [ ExceptionHandler ] ) ,
10183 bind ( EventManager ) . toFactory ( ( zone ) => {
10284 var plugins = [ new HammerGesturesPlugin ( ) , new DomEventsPlugin ( ) ] ;
@@ -136,8 +118,8 @@ function _injectorBindings(appComponentType): List<Binding> {
136118 UrlResolver ,
137119 StyleUrlResolver ,
138120 StyleInliner ,
139- PrivateComponentLoader ,
140- Testability ,
121+ DynamicComponentLoader ,
122+ Testability
141123 ] ;
142124}
143125
@@ -260,8 +242,8 @@ function _createVmZone(givenReporter:Function): VmTurnZone {
260242 * @publicModule angular2/angular2
261243 */
262244export function bootstrap ( appComponentType : Type ,
263- componentServiceBindings : List < Binding >= null ,
264- errorReporter : Function = null ) : Promise < Injector > {
245+ componentServiceBindings : List < Binding > = null ,
246+ errorReporter : Function = null ) : Promise < Injector > {
265247 BrowserDomAdapter . makeCurrent ( ) ;
266248 var bootstrapProcess = PromiseWrapper . completer ( ) ;
267249
@@ -272,11 +254,11 @@ export function bootstrap(appComponentType: Type,
272254
273255 var appInjector = _createAppInjector ( appComponentType , componentServiceBindings , zone ) ;
274256
275- PromiseWrapper . then ( appInjector . asyncGet ( appViewToken ) ,
276- ( rootView ) => {
257+ PromiseWrapper . then ( appInjector . asyncGet ( appChangeDetectorToken ) ,
258+ ( appChangeDetector ) => {
277259 // retrieve life cycle: may have already been created if injected in root component
278- var lc = appInjector . get ( LifeCycle ) ;
279- lc . registerWith ( zone , rootView . changeDetector ) ;
260+ var lc = appInjector . get ( LifeCycle ) ;
261+ lc . registerWith ( zone , appChangeDetector ) ;
280262 lc . tick ( ) ; //the first tick that will bootstrap the app
281263
282264 bootstrapProcess . resolve ( appInjector ) ;
0 commit comments