@@ -12,6 +12,8 @@ import {TemplateLoader} from './compiler/template_loader';
1212import { DirectiveMetadataReader } from './compiler/directive_metadata_reader' ;
1313import { AnnotatedType } from './compiler/annotated_type' ;
1414import { ListWrapper } from 'facade/collection' ;
15+ import { VmTurnZone } from 'core/zone/vm_turn_zone' ;
16+ import { LifeCycle } from 'core/life_cycle/life_cycle' ;
1517
1618var _rootInjector : Injector ;
1719
@@ -65,7 +67,8 @@ export function documentDependentBindings(appComponentType) {
6567 bind ( ChangeDetector ) . toFactory ( ( appRecordRange ) =>
6668 new ChangeDetector ( appRecordRange , assertionsEnabled ( ) ) , [ appRecordRangeToken ] ) ,
6769 bind ( appComponentType ) . toFactory ( ( rootView ) => rootView . elementInjectors [ 0 ] . getComponent ( ) ,
68- [ appViewToken ] )
70+ [ appViewToken ] ) ,
71+ bind ( LifeCycle ) . toClass ( LifeCycle )
6972 ] ;
7073}
7174
@@ -79,14 +82,16 @@ function _injectorBindings(appComponentType) {
7982export function bootstrap ( appComponentType : Type , bindings = null ) {
8083 // TODO(rado): prepopulate template cache, so applications with only
8184 // index.html and main.js are possible.
82- if ( isBlank ( _rootInjector ) ) _rootInjector = new Injector ( _rootBindings ) ;
83- var appInjector = _rootInjector . createChild ( _injectorBindings (
84- appComponentType ) ) ;
85- if ( isPresent ( bindings ) ) appInjector = appInjector . createChild ( bindings ) ;
8685
87- return appInjector . asyncGet ( ChangeDetector ) . then ( ( cd ) => {
88- // TODO(rado): replace with zone.
89- cd . detectChanges ( ) ;
90- return appInjector ;
86+ var zone = new VmTurnZone ( ) ;
87+ return zone . run ( ( ) => {
88+ if ( isBlank ( _rootInjector ) ) _rootInjector = new Injector ( _rootBindings ) ;
89+
90+ var appInjector = _rootInjector . createChild ( _injectorBindings ( appComponentType ) ) ;
91+ if ( isPresent ( bindings ) ) appInjector = appInjector . createChild ( bindings ) ;
92+
93+ return appInjector . asyncGet ( LifeCycle ) .
94+ then ( ( lc ) => lc . registerWith ( zone ) ) .
95+ then ( ( _ ) => appInjector ) ;
9196 } ) ;
9297}
0 commit comments