| 
									
										
										
										
											2018-05-14 08:37:43 -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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | /* tslint:disable:no-console  */ | 
					
						
							| 
									
										
										
										
											2019-01-28 21:59:25 +01:00
										 |  |  | import {Component, Directive, EventEmitter, NgModule} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2018-05-14 08:37:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion component-input
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'app-bank-account', | 
					
						
							|  |  |  |   inputs: ['bankName', 'id: account-id'], | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     Bank Name: {{ bankName }} | 
					
						
							|  |  |  |     Account Id: {{ id }} | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class BankAccountComponent { | 
					
						
							| 
									
										
										
										
											2018-06-25 11:36:35 -07:00
										 |  |  |   bankName: string|null = null; | 
					
						
							|  |  |  |   id: string|null = null; | 
					
						
							| 
									
										
										
										
											2018-05-14 08:37:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // this property is not bound, and won't be automatically updated by Angular
 | 
					
						
							| 
									
										
										
										
											2018-06-25 11:36:35 -07:00
										 |  |  |   normalizedBankName: string|null = null; | 
					
						
							| 
									
										
										
										
											2018-05-14 08:37:43 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'app-my-input', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <app-bank-account | 
					
						
							|  |  |  |       bankName="RBC" | 
					
						
							|  |  |  |       account-id="4747"> | 
					
						
							|  |  |  |     </app-bank-account> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class MyInputComponent { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion component-input
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion component-output-interval
 | 
					
						
							|  |  |  | @Directive({selector: 'app-interval-dir', outputs: ['everySecond', 'fiveSecs: everyFiveSeconds']}) | 
					
						
							|  |  |  | export class IntervalDirComponent { | 
					
						
							|  |  |  |   everySecond = new EventEmitter<string>(); | 
					
						
							|  |  |  |   fiveSecs = new EventEmitter<string>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     setInterval(() => this.everySecond.emit('event'), 1000); | 
					
						
							|  |  |  |     setInterval(() => this.fiveSecs.emit('event'), 5000); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'app-my-output', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <app-interval-dir | 
					
						
							|  |  |  |       (everySecond)="onEverySecond()" | 
					
						
							|  |  |  |       (everyFiveSeconds)="onEveryFiveSeconds()"> | 
					
						
							|  |  |  |     </app-interval-dir> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class MyOutputComponent { | 
					
						
							|  |  |  |   onEverySecond() { console.log('second'); } | 
					
						
							|  |  |  |   onEveryFiveSeconds() { console.log('five seconds'); } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-01-28 21:59:25 +01:00
										 |  |  | // #enddocregion component-output-interval
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @NgModule({ | 
					
						
							|  |  |  |   declarations: [BankAccountComponent, MyInputComponent, IntervalDirComponent, MyOutputComponent] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class AppModule { | 
					
						
							|  |  |  | } |