closes #1807 - e2e tests now also cover the tax calculator. - Dart app updated to match TS (it had no sales tax calculator). - TS sample source cleanup (e.g. removed many unnecessary `docregions`). - Prose updated to include @kwalrath's revisions from a while ago, Ward's comments, and some of my edits as well. Contributes to #1598 and #1508.
26 lines
664 B
TypeScript
26 lines
664 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);
|
|
}
|
|
}
|