@@ -7,26 +7,44 @@ import {ElementRef} from './element_ref';
77import  { ViewRef ,  HostViewRef }  from  './view_ref' ; 
88
99/** 
10-  * Represents a component instance as a node in application's component tree and provides access to 
11-  * other objects related to this component instance. 
10+  * Represents an instance of a Component created via {@link  DynamicComponentLoader}. 
11+  * 
12+  * `ComponentRef` provides access to the Component Instance as well other objects related to this 
13+  * Component Instance and allows you to destroy the Component Instance via the {@link  #dispose} 
14+  * method. 
1215 */ 
1316export  class  ComponentRef  { 
1417  /** 
15-    * Location of the component host element . 
18+    * Location of the Host Element of this Component Instance . 
1619   */ 
1720  location : ElementRef ; 
1821
1922  /** 
20-    * Instance  of component . 
23+    * The instance  of the Component . 
2124   */ 
2225  instance : any ; 
2326
27+   /** 
28+    * The user defined component type, represented via the constructor function. 
29+    * 
30+    * <!-- TODO: customize wording for Dart docs --> 
31+    */ 
2432  componentType : Type ; 
2533
34+   /** 
35+    * @private  
36+    * 
37+    * The injector provided {@link  DynamicComponentLoader#loadAsRoot}. 
38+    * 
39+    * TODO(i): this api is useless and should be replaced by an injector retrieved from 
40+    *     the HostElementRef, which is currently not possible. 
41+    */ 
2642  injector : Injector ; 
2743
2844  /** 
2945   * @private  
46+    * 
47+    * TODO(i): refactor into public/private fields 
3048   */ 
3149  constructor ( location : ElementRef ,  instance : any ,  componentType : Type ,  injector : Injector , 
3250              private  _dispose : ( )  =>  void )  { 
@@ -37,42 +55,61 @@ export class ComponentRef {
3755  } 
3856
3957  /** 
40-    * Returns the host  {@link  ViewRef}. 
58+    * The  {@link  ViewRef} of the Host View of this Component instance . 
4159   */ 
4260  get  hostView ( ) : HostViewRef  {  return  this . location . parentView ;  } 
4361
62+   /** 
63+    * @private  
64+    * 
65+    * Returns the type of this Component instance. 
66+    * 
67+    * TODO(i): this api should be removed 
68+    */ 
4469  get  hostComponentType ( ) : Type  {  return  this . componentType ;  } 
4570
71+   /** 
72+    * @private  
73+    * 
74+    * The instance of the component. 
75+    * 
76+    * TODO(i): this api should be removed 
77+    */ 
4678  get  hostComponent ( ) : any  {  return  this . instance ;  } 
4779
4880  /** 
49-    * Dispose of the component instance. 
81+    * Destroys the component instance and all of the data structures associated with it. 
82+    * 
83+    * TODO(i): rename to destroy to be consistent with AppViewManager and ViewContainerRef 
5084   */ 
5185  dispose ( )  {  this . _dispose ( ) ;  } 
5286} 
5387
5488/** 
55-  * Service for creating an instance of a component and attaching it to the component tree of an 
56-  * application at a specified location. 
89+  * Service for instantiating a Component and attaching it to a View at a specified location. 
5790 */ 
5891@Injectable ( ) 
5992export  class  DynamicComponentLoader  { 
60- 
6193  /** 
6294   * @private  
6395   */ 
6496  constructor ( private  _compiler : Compiler ,  private  _viewManager : AppViewManager )  { } 
6597
6698  /** 
67-    * Loads a root component that is placed at the first element that matches the component's 
68-    * selector. 
99+    * Creates an instance of a Component `type` and attaches it to the first element in the 
100+    * platform-specific global view that matches the component's selector. 
101+    * 
102+    * In a browser the platform-specific global view is the main DOM Document. 
69103   * 
70-    * - `typeOrBinding` `Type` - representing the component to load. 
71-    * - `overrideSelector` (optional) selector to load the component at (or use 
72-    *   `@Component.selector`) The selector can be anywhere (i.e. outside the current component.) 
73-    * - `injector` {@link  Injector} - optional injector to use for the component. 
104+    * If needed, the component's selector can be overridden via `overrideSelector`. 
74105   * 
75-    * The loaded component receives injection normally as a hosted view. 
106+    * You can optionally provide `injector` and this {@link  Injector} will be used to instantiate the 
107+    * Component. 
108+    * 
109+    * To be notified when this Component instance is destroyed, you can also optionally provide 
110+    * `onDispose` callback. 
111+    * 
112+    * Returns a promise for the {@link  ComponentRef} representing the newly created Component. 
76113   * 
77114   * 
78115   * ## Example 
@@ -137,10 +174,18 @@ export class DynamicComponentLoader {
137174  } 
138175
139176  /** 
140-    * Loads a component into the component view of the provided ElementRef next to the element 
141-    * with the given name. 
177+    * Creates an instance of a Component and attaches it to a View Container located inside of the 
178+    * Component View of another Component instance. 
179+    * 
180+    * The targeted Component Instance is specified via its `hostLocation` {@link  ElementRef}. The 
181+    * location within the Component View of this Component Instance is specified via `anchorName` 
182+    * Template Variable Name. 
183+    * 
184+    * You can optionally provide `bindings` to configure the {@link  Injector} provisioned for this 
185+    * Component Instance. 
186+    * 
187+    * Returns a promise for the {@link  ComponentRef} representing the newly created Component. 
142188   * 
143-    * The loaded component receives injection normally as a hosted view. 
144189   * 
145190   * ## Example 
146191   * 
@@ -190,9 +235,13 @@ export class DynamicComponentLoader {
190235  } 
191236
192237  /** 
193-    * Loads a component next to the provided ElementRef. 
238+    * Creates an instance of a Component and attaches it to the View Container found at the 
239+    * `location` specified as {@link  ElementRef}. 
240+    * 
241+    * You can optionally provide `bindings` to configure the {@link  Injector} provisioned for this 
242+    * Component Instance. 
194243   * 
195-    * The loaded component receives injection normally as a hosted view . 
244+    * Returns a promise for the { @link  ComponentRef} representing the newly created Component . 
196245   * 
197246   * 
198247   * ## Example 
@@ -216,7 +265,7 @@ export class DynamicComponentLoader {
216265   * }) 
217266   * class MyApp { 
218267   *   constructor(dynamicComponentLoader: ng.DynamicComponentLoader, elementRef: ng.ElementRef) { 
219-    *     dynamicComponentLoader.loadIntoLocation (ChildComponent, elementRef, 'child' ); 
268+    *     dynamicComponentLoader.loadNextToLocation (ChildComponent, elementRef); 
220269   *   } 
221270   * } 
222271   * 
0 commit comments