Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getPrice(strCode: string) {
- if (strCode == "" || strCode == undefined) {
- this.showMessage("strCode is missing");
- return {"price": 0, "percentChange": 0};
- } else {
- let loading = this.loadingCtrl.create({
- content: 'Please wait...',
- spinner: 'dots'
- });
- loading.present();
- this.restProvider.getItemPrice(strCode).subscribe(priceInfo => {
- loading.dismiss();
- this.priceInfo = priceInfo;
- if (this.priceInfo.failed != "") {
- this.showMessage("Failed to find " + this.priceInfo.failed);
- return {"price": 0, "percentChange": 0};
- } else {
- return {"price": this.priceInfo.response[0].price, "percentChange": this.priceInfo.response[0].percent_change};
- }
- });
- }
- }
- <button ion-button (click)="getPrice()">Get Price</button>
- getPrice() {
- let priceInfo1;
- new Promise((resolve) => {this.helper.getPrice(this.transactionInfo.strCode)}).then(
- priceInfo => {
- priceInfo1 = priceInfo;
- this.transactionInfo.itemPrice = priceInfo1.price;
- });
- }
- let priceInfo = this.helper.getPrice(itemInfo.strCode);
Add Comment
Please, Sign In to add comment