*ngIf with providers updated from events

I have a simple support page that shows the most recent unhandled exception, if there is one. In my custom ErrorHandler I publish an event, which then sets error values on a provider, which the view binds to via *ngif.

This whole thing works if the error is not on the support page, because the support view is re-loaded. If an error happens on the support page, the view never updates itself (until the next re-load). Any ideas?

View:

ion-card *ngIf="loggingService.lastUnhandledErrorMessage">
      <ion-card-header>
        <ion-icon name="alert"></ion-icon> Recent Error !
      </ion-card-header>

Error Handler / Service

this.events.subscribe(Constants.EVENT_ERROR_UNHANDLED, (error) =>{
  if(error){
    if(error.message){
      this.loggingService.lastUnhandledErrorMessage = error.message;
    }
  }
});

How are you calling this subscribe method? View updates based on the lifecycle where this is called. Please share the complete code for the service. Also refer to the lifecycle events to place your call as needed.

See my answer on the Scroll to Specific element thread.

The event subscription happens on application startup. The event is firing, and the property on the service is updated. The ngIf just doesn’t pick it up unless I re-load the page.

Are we absolutely certain that the view in question has the same instance of the logging service as the error handler that is setting the unhandled error message?

You could try changing your ngIf to bind to the result of a function hasError() in the view’s controller. In addition to perhaps solving the problem outright, that will allow you to set a breakpoint in that function and investigate.

Same issue here. After subscribing an event, ngif does not update its condition.