Variable won't get updated in view


#1

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]

#2

#3

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()