| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  | // #docplaster
 | 
					
						
							|  |  |  | // #docregion
 | 
					
						
							|  |  |  | // #docregion unless-declaration
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Directive, Input } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #enddocregion unless-declaration
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { TemplateRef, ViewContainerRef } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion unless-declaration
 | 
					
						
							|  |  |  | @Directive({ selector: '[myUnless]' }) | 
					
						
							|  |  |  | export class UnlessDirective { | 
					
						
							|  |  |  |   // #enddocregion unless-declaration
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion unless-constructor
 | 
					
						
							|  |  |  |   constructor( | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     private templateRef: TemplateRef<any>, | 
					
						
							|  |  |  |     private viewContainer: ViewContainerRef | 
					
						
							| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  |     ) { } | 
					
						
							|  |  |  |   // #enddocregion unless-constructor
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion unless-set
 | 
					
						
							|  |  |  |   @Input() set myUnless(condition: boolean) { | 
					
						
							|  |  |  |     if (!condition) { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |       this.viewContainer.createEmbeddedView(this.templateRef); | 
					
						
							| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |       this.viewContainer.clear(); | 
					
						
							| 
									
										
										
										
											2015-11-13 14:47:42 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion unless-set
 | 
					
						
							|  |  |  |   // #docregion unless-declaration
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion unless-declaration
 | 
					
						
							|  |  |  | // #enddocregion
 |