Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created December 16, 2019 04:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save IntegerMan/547d5a73b19073e6b2be25189074803e to your computer and use it in GitHub Desktop.
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