Guest User

Untitled

a guest
May 21st, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. getPrice(strCode: string) {
  2. if (strCode == "" || strCode == undefined) {
  3. this.showMessage("strCode is missing");
  4. return {"price": 0, "percentChange": 0};
  5. } else {
  6. let loading = this.loadingCtrl.create({
  7. content: 'Please wait...',
  8. spinner: 'dots'
  9. });
  10. loading.present();
  11. this.restProvider.getItemPrice(strCode).subscribe(priceInfo => {
  12. loading.dismiss();
  13. this.priceInfo = priceInfo;
  14. if (this.priceInfo.failed != "") {
  15. this.showMessage("Failed to find " + this.priceInfo.failed);
  16. return {"price": 0, "percentChange": 0};
  17. } else {
  18. return {"price": this.priceInfo.response[0].price, "percentChange": this.priceInfo.response[0].percent_change};
  19. }
  20. });
  21. }
  22. }
  23.  
  24. <button ion-button (click)="getPrice()">Get Price</button>
  25.  
  26. getPrice() {
  27. let priceInfo1;
  28. new Promise((resolve) => {this.helper.getPrice(this.transactionInfo.strCode)}).then(
  29. priceInfo => {
  30. priceInfo1 = priceInfo;
  31. this.transactionInfo.itemPrice = priceInfo1.price;
  32. });
  33. }
  34.  
  35. let priceInfo = this.helper.getPrice(itemInfo.strCode);
Add Comment
Please, Sign In to add comment