| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | import {Attribute, Component, Directive, Pipe} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-22 19:51:03 +02:00
										 |  |  | class CustomDirective {} | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 12:51:01 -07:00
										 |  |  | @Component({selector: 'greet', template: 'Hello {{name}}!'}) | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  | class Greet { | 
					
						
							|  |  |  |   name: string = 'World'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion attributeFactory
 | 
					
						
							|  |  |  | @Component({selector: 'page', template: 'Title: {{title}}'}) | 
					
						
							|  |  |  | class Page { | 
					
						
							|  |  |  |   title: string; | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |   constructor(@Attribute('title') title: string) { | 
					
						
							|  |  |  |     this.title = title; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion attributeMetadata
 | 
					
						
							|  |  |  | @Directive({selector: 'input'}) | 
					
						
							|  |  |  | class InputAttrDirective { | 
					
						
							| 
									
										
										
										
											2016-02-11 17:01:17 -08:00
										 |  |  |   constructor(@Attribute('type') type: string) { | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  |     // type would be 'text' in this example
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: 'input'}) | 
					
						
							|  |  |  | class InputDirective { | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     // Add some logic.
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Pipe({name: 'lowercase'}) | 
					
						
							|  |  |  | class Lowercase { | 
					
						
							| 
									
										
										
										
											2020-04-13 16:40:21 -07:00
										 |  |  |   transform(v: string, args: any[]) { | 
					
						
							|  |  |  |     return v.toLowerCase(); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-11-30 08:28:54 -08:00
										 |  |  | } |