Buildin publish-subscribe Eventbus stopped working in Lazy Loading app

Hi,

I recently upgraded my 35+ page app to use lazy loading and overall the upgrade was easy and the result looks very good.

Note: I used a npm script to generated most module.ts files and do some cleanup. It might be helpful.

But I ran into a rather big problem with Ionic’s buildin publish-subscribe style eventbus. It’s nice to have sth in the framework and I use it mostly for publishing navigation events with multiple navController target.

Unfortunatly it stopped working after the upgrade.

I think the problem was caused new instances of Events wher injected into my pages instead of a singleton.

Fix 1:
Add the Events as provider to your app/app.component.ts. This wasn’t needed before lazy loading!

import {Component, OnInit, ViewChild} from "@angular/core";
import {AuthService} from "../providers/auth-service";
import {NetworkService} from "../providers/network-service";
import {WindowService} from "../providers/window-service";

import {Events} from "ionic-angular";

@Component({
  templateUrl: 'app.html',
  providers: [AuthService, NetworkService, WindowService, Events]
})
export class AppComponent implements OnInit {

This fixed most of my navigation issues but one problem with the PopoverController stayed.

 presentPopoverActions(event: Event) {
  this.actionPopover = this.popoverCtrl.create('ActionPopoverPage', {options: options});
  this.actionPopover.present({ev: event});
}

ActionPopoverPage requires a injected instance of Events. This stays broken, although I was able to use another approach.

Maybe any one had that problem as well and can point me into a direction.

Thanks and BR,
Michael