1- 
21import  { NgZone }  from  'angular2/src/core/zone/ng_zone' ; 
32import  { Type ,  isBlank ,  isPresent ,  assertionsEnabled }  from  'angular2/src/core/facade/lang' ; 
43import  { bind ,  Binding ,  Injector ,  OpaqueToken }  from  'angular2/src/core/di' ; 
@@ -47,9 +46,12 @@ import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mappe
4746
4847
4948/** 
50-  * Contains everything that is safe to share between applications. 
49+  * Constructs the set of bindings meant for use at the platform level. 
50+  * 
51+  * These are bindings that should be singletons shared among all Angular applications 
52+  * running on the page. 
5153 */ 
52- export  function  rootBindings ( ) : Array < Type  |  Binding  |  any [ ] >  { 
54+ export  function  platformBindings ( ) : Array < Type  |  Binding  |  any [ ] >  { 
5355  return  [ bind ( Reflector ) . toValue ( reflector ) ,  TestabilityRegistry ] ; 
5456} 
5557
@@ -145,18 +147,19 @@ export function platformCommon(bindings?: Array<Type | Binding | any[]>, initial
145147  } 
146148
147149  if  ( isBlank ( bindings ) )  { 
148-     bindings  =  rootBindings ( ) ; 
150+     bindings  =  platformBindings ( ) ; 
149151  } 
150152  _platform  =  new  PlatformRef ( Injector . resolveAndCreate ( bindings ) ,  ( )  =>  {  _platform  =  null ;  } ) ; 
151153  return  _platform ; 
152154} 
153155
154156/** 
155-  * Represent the Angular context on a page, and is a true singleton. 
157+  * The Angular platform is the entry point for Angular on a web page. Each page 
158+  * has exactly one platform, and services (such as reflection) which are common 
159+  * to every Angular application running on the page are bound in its scope. 
156160 * 
157-  * The platform {@link  Injector} injects dependencies which are also 
158-  * truly singletons in the context of a page (such as the browser's 
159-  * cookie jar). 
161+  * A page's platform is initialized implicitly when {@link  bootstrap}() is called, or 
162+  * explicitly by calling {@link  platform}(). 
160163 */ 
161164export  class  PlatformRef  { 
162165  /** 
@@ -170,25 +173,55 @@ export class PlatformRef {
170173  constructor ( private  _injector : Injector ,  private  _dispose : ( )  =>  void )  { } 
171174
172175  /** 
173-    * Get the platform {@link  Injector}. 
176+    * Retrieve the platform {@link  Injector}, which is the parent injector for 
177+    * every Angular application on the page and provides singleton bindings. 
174178   */ 
175179  get  injector ( ) : Injector  {  return  this . _injector ;  } 
176180
177181  /** 
178-    * Build a new Angular application with the given bindings. The `ApplicationRef` 
179-    * returned can be used to bootstrap one or more root components within the 
180-    * application. 
182+    * Instantiate a new Angular application on the page. 
183+    * 
184+    * # What is an application? 
185+    * 
186+    * Each Angular application has its own zone, change detection, compiler, 
187+    * renderer, and other framework components. An application hosts one or more 
188+    * root components, which can be initialized via `ApplicationRef.bootstrap()`. 
189+    * 
190+    * # Application Bindings 
191+    * 
192+    * Angular applications require numerous bindings to be properly instantiated. 
193+    * When using `application()` to create a new app on the page, these bindings 
194+    * must be provided. Fortunately, there are helper functions to configure 
195+    * typical bindings, as shown in the example below. 
196+    * 
197+    * # Example 
198+    * ``` 
199+    * var myAppBindings = [MyAppService]; 
200+    * 
201+    * platform() 
202+    *   .application([applicationCommonBindings(), applicationDomBindings(), myAppBindings]) 
203+    *   .bootstrap(MyTopLevelComponent); 
204+    * ``` 
205+    * # See Also 
206+    * 
207+    * See the {@link  bootstrap} documentation for more details. 
181208   */ 
182209  application ( bindings : Array < Type  |  Binding  |  any [ ] > ) : ApplicationRef  { 
183210    var  app  =  this . _initApp ( createNgZone ( ) ,  bindings ) ; 
184211    return  app ; 
185212  } 
186213
187214  /** 
188-    * Build a new Angular application from asynchronously provided bindings. 
215+    * Instantiate a new Angular application on the page, using bindings which 
216+    * are only available asynchronously. One such use case is to initialize an 
217+    * application running in a web worker. 
189218   * 
190-    * Runs the `AsyncLoader` callback in the application `Zone` and constructs 
191-    * a new Application from the bindings provided by the `Promise` it returns. 
219+    * # Usage 
220+    * 
221+    * `bindingFn` is a function that will be called in the new application's zone. 
222+    * It should return a {@link  Promise} to a list of bindings to be used for the 
223+    * new application. Once this promise resolves, the application will be 
224+    * constructed in the same manner as a normal `application()`. 
192225   */ 
193226  asyncApplication ( bindingFn : ( zone : NgZone )  => 
194227                       Promise < Array < Type  |  Binding  |  any [ ] > > ) : Promise < ApplicationRef >  { 
@@ -242,11 +275,9 @@ export class PlatformRef {
242275} 
243276
244277/** 
245-  * Represents  an Angular application. 
278+  * A reference to  an Angular application running on a page . 
246279 * 
247-  * Use to retrieve the application {@link  Injector} or to bootstrap new 
248-  * components at the root of the application. Can also be used to dispose 
249-  * of the entire application and all its loaded components. 
280+  * For more about Angular applications, see the documentation for {@link  bootstrap}. 
250281 */ 
251282export  class  ApplicationRef  { 
252283  private  _bootstrapListeners : Function [ ]  =  [ ] ; 
@@ -258,15 +289,34 @@ export class ApplicationRef {
258289  constructor ( private  _platform : PlatformRef ,  private  _zone : NgZone ,  private  _injector : Injector )  { } 
259290
260291  /** 
261-    * Register a listener to be called each time a new root component type is bootstrapped. 
292+    * Register a listener to be called each time `bootstrap()` is called to bootstrap 
293+    * a new root component. 
262294   */ 
263295  registerBootstrapListener ( listener : ( ref : ComponentRef )  =>  void ) : void { 
264296    this . _bootstrapListeners . push ( listener ) ; 
265297  } 
266298
267299  /** 
268-    * Bootstrap a new component at the root level of the application, optionally with 
269-    * component specific bindings. 
300+    * Bootstrap a new component at the root level of the application. 
301+    * 
302+    * # Bootstrap process 
303+    * 
304+    * When bootstrapping a new root component into an application, Angular mounts the 
305+    * specified application component onto DOM elements identified by the [componentType]'s 
306+    * selector and kicks off automatic change detection to finish initializing the component. 
307+    * 
308+    * # Optional Bindings 
309+    * 
310+    * Bindings for the given component can optionally be overridden via the `bindings` 
311+    * parameter. These bindings will only apply for the root component being added and any 
312+    * child components under it. 
313+    * 
314+    * # Example 
315+    * ``` 
316+    * var app = platform.application([applicationCommonBindings(), applicationDomBindings()]; 
317+    * app.bootstrap(FirstRootComponent); 
318+    * app.bootstrap(SecondRootComponent, [bind(OverrideBinding).toClass(OverriddenBinding)]); 
319+    * ``` 
270320   */ 
271321  bootstrap ( componentType : Type ,  bindings ?: Array < Type  |  Binding  |  any [ ] > ) : Promise < ComponentRef >  { 
272322    var  completer  =  PromiseWrapper . completer ( ) ; 
@@ -312,6 +362,9 @@ export class ApplicationRef {
312362   */ 
313363  get  zone ( ) : NgZone  {  return  this . _zone ;  } 
314364
365+   /** 
366+    * Dispose of this application and all of its components. 
367+    */ 
315368  dispose ( ) : void { 
316369    // TODO(alxhub): Dispose of the NgZone. 
317370    this . _rootComponents . forEach ( ( ref )  =>  ref . dispose ( ) ) ; 
0 commit comments