Performing a project with ionic 3 I had a very strange problem, I'm working on my file ts
I use two variable of type number, but in my file html
I have two elements <ion-input>
of type="number"
and with the directive [(ngModel)]
, but when modifying the values of the variables by keyboard my file ts
begins to understand these variable as type string
, I leave the code below, the subject is that I compare if one number is greater than another but it gives me unexpected results
page.ts
variable1: number;
variable2: number;
constructor() {
var variableMayor
if(this.variable1 > this.variable2){
variableMayor = this.variable1
console.log('variable mayor es variable1', variableMayor )
}else{
variableMayor = this.variable2
console.log('variable mayor es variable2', variableMayor )
}
}
page.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Page</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-row >
<ion-col col-6 >
<h6 >Variable</h6>
<ion-input [(ngModel)]="variable1" type="number" ></ion-input>
</ion-col>
<ion-col col-6 >
<h6 >Variable</h6>
<ion-input [(ngModel)]="variable2" type="number" ></ion-input>
</ion-col>
</ion-row>
</ion-content>