Created
December 16, 2019 04:10
-
-
Save IntegerMan/547d5a73b19073e6b2be25189074803e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
import {MathService} from '../math.service'; | |
@Component({ | |
selector: 'app-calculator', | |
templateUrl: './calculator.component.html', | |
styleUrls: ['./calculator.component.css'] | |
}) | |
export class CalculatorComponent { | |
XValue = '2'; | |
YValue = '2'; | |
Results: string; | |
constructor(private math: MathService) { } | |
onAddClick() { | |
this.math.add(this.XValue, this.YValue).then(r => this.Results = `${this.XValue} + ${this.YValue} = ${r}`); | |
} | |
onSubClick() { | |
this.math.subtract(this.XValue, this.YValue).then(r => this.Results = `${this.XValue} - ${this.YValue} = ${r}`); | |
} | |
onMultClick() { | |
this.math.multiply(this.XValue, this.YValue).then(r => this.Results = `${this.XValue} * ${this.YValue} = ${r}`); | |
} | |
onDivClick() { | |
this.math.divide(this.XValue, this.YValue).then(r => this.Results = `${this.XValue} / ${this.YValue} = ${r}`); | |
} | |
onPowClick() { | |
this.math.power(this.XValue, this.YValue).then(r => this.Results = `${this.XValue} ^ ${this.YValue} = ${r}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment