| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-17 08:56:49 -08:00
										 |  |  | import {ApplicationRef} from '../application_ref'; | 
					
						
							| 
									
										
										
										
											2015-08-06 13:19:29 -07:00
										 |  |  | import {ChangeDetectorRef} from '../change_detection/change_detector_ref'; | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-04 14:40:37 -07:00
										 |  |  | export abstract class ViewRef extends ChangeDetectorRef { | 
					
						
							| 
									
										
										
										
											2016-11-24 11:32:28 +01:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Destroys the view and all of the data structures associated with it. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   abstract destroy(): void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-28 13:36:56 -07:00
										 |  |  |   abstract get destroyed(): boolean; | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 15:45:15 -07:00
										 |  |  |   abstract onDestroy(callback: Function): any /** TODO #9100 */; | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-11 17:26:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * Represents an Angular View. | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * <!-- TODO: move the next two paragraphs to the dev guide --> | 
					
						
							|  |  |  |  * A View is a fundamental building block of the application UI. It is the smallest grouping of | 
					
						
							|  |  |  |  * Elements which are created and destroyed together. | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * Properties of elements in a View can change, but the structure (number and order) of elements in | 
					
						
							| 
									
										
										
										
											2015-09-21 12:32:25 -07:00
										 |  |  |  * a View cannot. Changing the structure of Elements can only be done by inserting, moving or | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * removing nested Views via a `ViewContainerRef`. Each View can contain many View Containers. | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * <!-- /TODO --> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * @usageNotes | 
					
						
							| 
									
										
										
										
											2015-10-19 15:37:32 +01:00
										 |  |  |  * ### Example | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * Given this template... | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * Count: {{items.length}} | 
					
						
							|  |  |  |  * <ul> | 
					
						
							| 
									
										
										
										
											2016-04-25 19:52:24 -07:00
										 |  |  |  *   <li *ngFor="let  item of items">{{item}}</li> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * </ul> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * We have two `TemplateRef`s: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Outer `TemplateRef`: | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * Count: {{items.length}} | 
					
						
							|  |  |  |  * <ul> | 
					
						
							| 
									
										
										
										
											2017-01-09 13:16:46 -08:00
										 |  |  |  *   <ng-template ngFor let-item [ngForOf]="items"></ng-template> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * </ul> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * Inner `TemplateRef`: | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * ```
 | 
					
						
							|  |  |  |  *   <li>{{item}}</li> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * Notice that the original template is broken down into two separate `TemplateRef`s. | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-05-18 16:13:00 +01:00
										 |  |  |  * The outer/inner `TemplateRef`s are then assembled into views like so: | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2015-07-11 17:26:48 +02:00
										 |  |  |  * <!-- ViewRef: outer-0 --> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * Count: 2 | 
					
						
							|  |  |  |  * <ul> | 
					
						
							| 
									
										
										
										
											2017-01-09 13:16:46 -08:00
										 |  |  |  *   <ng-template view-container-ref></ng-template> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  *   <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 --> | 
					
						
							|  |  |  |  *   <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 --> | 
					
						
							|  |  |  |  * </ul> | 
					
						
							| 
									
										
										
										
											2015-07-11 17:26:48 +02:00
										 |  |  |  * <!-- /ViewRef: outer-0 --> | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2016-05-25 15:00:05 -07:00
										 |  |  |  * @experimental | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-04-28 14:00:31 -07:00
										 |  |  | export abstract class EmbeddedViewRef<C> extends ViewRef { | 
					
						
							| 
									
										
										
										
											2017-09-28 13:36:56 -07:00
										 |  |  |   abstract get context(): C; | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-28 13:36:56 -07:00
										 |  |  |   abstract get rootNodes(): any[]; | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-17 08:56:49 -08:00
										 |  |  | export interface InternalViewRef extends ViewRef { | 
					
						
							| 
									
										
										
										
											2017-02-22 10:05:56 -08:00
										 |  |  |   detachFromAppRef(): void; | 
					
						
							| 
									
										
										
										
											2017-02-17 08:56:49 -08:00
										 |  |  |   attachToAppRef(appRef: ApplicationRef): void; | 
					
						
							|  |  |  | } |