| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Component }       from '@angular/core'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { SalesTaxService } from './sales-tax.service'; | 
					
						
							|  |  |  | import { TaxRateService }  from './tax-rate.service'; | 
					
						
							| 
									
										
										
										
											2015-12-17 13:49:33 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector:    'sales-tax', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <h2>Sales Tax Calculator</h2> | 
					
						
							|  |  |  |     Amount: <input #amountBox (change)="0"> | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 19:59:34 -08:00
										 |  |  |     <div *ngIf="amountBox.value"> | 
					
						
							| 
									
										
										
										
											2015-12-17 13:49:33 -08:00
										 |  |  |     The sales tax is | 
					
						
							|  |  |  |      {{ getTax(amountBox.value) | currency:'USD':true:'1.2-2' }} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   `,
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   providers: [SalesTaxService, TaxRateService] | 
					
						
							| 
									
										
										
										
											2015-12-17 13:49:33 -08:00
										 |  |  | }) | 
					
						
							|  |  |  | export class SalesTaxComponent { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   constructor(private salesTaxService: SalesTaxService) { } | 
					
						
							| 
									
										
										
										
											2015-12-17 13:49:33 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   getTax(value: string | number) { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     return this.salesTaxService.getVAT(value); | 
					
						
							| 
									
										
										
										
											2015-12-17 13:49:33 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | } |