i choose this answer over the type="number" one becouse users can just press f12 and get rid of it
adding
type="number"
to my html works but that still doesn't explain why an - works without adding it to
for the minus is what i thought it works becouse - is not an string opperator and + is
I was testing with typescript and I noticed this so when I use minus it works when I use + it does work and I don't know how and can't find where I can find it
my class:
export class Add {
number1: Number;
number2: Number;
total: Number;
}
i have tried giving them into let this is my function
Math(): void {
let numberone = this.add.number1;
let numbertwo = this.add.number2;
this.add.total = numberone + numbertwo;
}
expected result where
numberone = 10
numbertwo = 10
this.add.total = numerone + numbertwo
that the total is becoming 20 but it becomes 1010
my html
<h2>here you can add stuff</h2>
<div><span>first number: </span><input [(ngModel)]="add.number1"
placeholder="number1"></div>
<div><span>second number: </span><input [(ngModel)]="add.number2"
placeholder="number2"></div>
<button (click)="Math()">press here to add</button> <label>{{add.total}}</label>