|
@@ -9,7 +9,7 @@ import {CalculatorService} from "../calculator.service";
|
|
|
export class CalculatorComponent implements OnInit {
|
|
export class CalculatorComponent implements OnInit {
|
|
|
value1 : number = 0;
|
|
value1 : number = 0;
|
|
|
value2 : number = 0;
|
|
value2 : number = 0;
|
|
|
- result : number = 0;
|
|
|
|
|
|
|
+ result : number | null = null;
|
|
|
message : string = "";
|
|
message : string = "";
|
|
|
operators : string[];
|
|
operators : string[];
|
|
|
|
|
|
|
@@ -24,12 +24,10 @@ export class CalculatorComponent implements OnInit {
|
|
|
console.log(this.value1 + " " + operator + " " + this.value2);
|
|
console.log(this.value1 + " " + operator + " " + this.value2);
|
|
|
this.calculatorService.calculate(operator, this.value1, this.value2).subscribe(
|
|
this.calculatorService.calculate(operator, this.value1, this.value2).subscribe(
|
|
|
(response) => {
|
|
(response) => {
|
|
|
- this.message = "";
|
|
|
|
|
- if (response.body != null) {
|
|
|
|
|
- this.result = response.body;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.result = response.body;
|
|
|
},
|
|
},
|
|
|
(error) => {
|
|
(error) => {
|
|
|
|
|
+ this.result = null;
|
|
|
if (error.status == 400) {
|
|
if (error.status == 400) {
|
|
|
this.message = "invalid input: " + error.error;
|
|
this.message = "invalid input: " + error.error;
|
|
|
} else {
|
|
} else {
|