Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70920

How to subtract number method parameters

$
0
0

export class Tab2Page implements OnInit {
categories: AngularFireList;
userBlnc // balance amount of user in database
pricebuy:Number = 0 // price number coming from method parameters

constructor( public af: AngularFireDatabase,public afAuth: AngularFireAuth, public router: Router,
public a : LoadingController,public m : AlertController){}

ngOnInit(): void {
this.afAuth.authState.subscribe(async user => {
if (user) {
let a = await this.a.create({})
a.present();
this.af.list("/users/"+user.uid+’/profile’).valueChanges().subscribe((data: any) => {
this.userBlnc = data;
})
} else {
this.router.navigate([‘signin’])
}

})

}

// getting price parameters
async open(a){
const alert = await this.m.create({
cssClass: ‘my-custom-class’,
message: “شراء فئة” + a.name + " بسعر " + a.price + " د٫ع ",
buttons: [
{
text: ‘الغاء’,
role: ‘cancel’,
handler: () => {
console.log(‘Confirm Cancel’);
}
}, {
text: ‘شراء’,
cssClass:‘btn_buy’,
handler: () => {
this.cut(a);
}
}
]
});

await alert.present();

}

// method excite to subtract price number
async cut(a){
console.log(this.userBlnc[0])
this.pricebuy = a.price
this.userBlnc[0]
let fpaValue : number=0
if (Number(a.price) && Number(this.userBlnc[0])) {
if (Number(this.userBlnc[0]) > Number(a.price)) {
fpaValue = Number(a.price) - Number(this.userBlnc[0]);
console.log(fpaValue)
alert(fpaValue)
} else{
alert(‘no balance engough’)
}
}

}

}

the output is NaN. any idea please?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70920

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>