angular-cn/public/docs/_examples/architecture/ts/app/sales-tax.component.ts
2016-08-09 11:48:07 -07:00

26 lines
662 B
TypeScript

import { Component } from '@angular/core';
import { SalesTaxService } from './sales-tax.service';
import { TaxRateService } from './tax-rate.service';
@Component({
selector: 'sales-tax',
template: `
<h2>Sales Tax Calculator</h2>
Amount: <input #amountBox (change)="0">
<div *ngIf="amountBox.value">
The sales tax is
{{ getTax(amountBox.value) | currency:'USD':true:'1.2-2' }}
</div>
`,
providers: [SalesTaxService, TaxRateService]
})
export class SalesTaxComponent {
constructor(private salesTaxService: SalesTaxService) { }
getTax(value: string | number) {
return this.salesTaxService.getVAT(value);
}
}