Variable won't get updated in view

Hi there!

I’m trying to update a variable within OneSignal notification handler, but it just won’t get updated in the view.

Does anyone know why is that?

Related code

    this.oneSignal.handleNotificationReceived().subscribe((notification) => {
      this.order = {company: {name: "Something"}}
      console.log(">>> Got here")
    })

Logs

[19:59:40]  console.log: >>> Got here
[19:59:40]  console.log: [object Object]

Thanks @AaronSterling, that worked!

The solution:

import { Component, ChangeDetectorRef } from '@angular/core'

...

// constructor
  private changeDetectorRef: ChangeDetectorRef,

...

// on success ajax request
    this.order = order
    this.changeDetectorRef.detectChanges()
1 Like