Skip to content

Instantly share code, notes, and snippets.

@MrPrashantT
Created January 30, 2018 10:50
Show Gist options
  • Save MrPrashantT/f17aa59c17802325ad1ff58c4ae461b4 to your computer and use it in GitHub Desktop.
Save MrPrashantT/f17aa59c17802325ad1ff58c4ae461b4 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import {FormGroup,FormControl,Validators} from '@angular/forms'
import { dashCaseToCamelCase } from '@angular/compiler/src/util';
@Component({
selector: 'app-fuel-calculation',
templateUrl: './fuel-calculation.component.html',
styleUrls: ['./fuel-calculation.component.css'],
})
export class FuelCalculationComponent implements OnInit {
form = new FormGroup({
amount : new FormControl('', Validators.required),
fuelPrice : new FormControl('', Validators.required),
discountSum : new FormControl('', Validators.required )
});
amountTotal;
discountTotal;
total;
fuelTotal;
// amountTotal=this.form.controls.amount.value;
// discountTotal=this.form.controls.discountSum.value;
// fuelTotal =this.form.controls.fuelPrice.value;
Calc(){
this.amountTotal = this.form.controls.amount.value;
this.discountTotal = this.form.controls.discountSum.value;
this.fuelTotal = this.form.controls.fuelPrice.value;
this.total = (this.amountTotal/this.fuelTotal) * (this.fuelTotal - this.discountTotal);
console.log(this.total);
}
ngOnInit() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment