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

Subscribe set Global Variables

$
0
0

@FoxDev wrote:

Hey guys,
i do get my Coupons over a subscribe function which is called when i initialize my page.

  private Initialize() {
    
    let id = this.activatedRoute.snapshot.paramMap.get('id');
    
    console.log("id: " + id);
    if (id) {
      this.CouponSubscription = this.couponController.GetCouponsByEmail('info@foxdev.ch').subscribe(res => {
        console.log(res);

        this.Coupon = res.find(x => x.id === id);
        //console.log(this.Coupon.DateOfRedeem.toMillis());
        this.isRedeemed = this.Coupon.DateOfRedeem.toMillis() != 0;
        this.isVaildDate = this.Coupon.DateOfActivation.toMillis() <= Date.now() && this.Coupon.DateOfExpiration.toMillis() >= Date.now();
      }); 
    }
  }

But the do not get set there because the object is undefined. Do i have to wait for these get loaded?
Can somebody help me?
Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles