Ionic 2 Events, publish and subscribe not working

前端 未结 3 2115
心在旅途
心在旅途 2021-01-18 12:04

I\'m trying to use Publish and Subscribe from ionic-angular

But I am not receiving any data nor error. Here are my codes

Page 1

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 12:16

    Having read the posts here and other forums, seems like the part about subscribing to an event is rather tricky. I gather that understanding lifecycle hooks and how promises work is important to getting around the problem. The following works if you want a second page to be able to subscribe to a published event on an existing page:

    this.navCtrl.setRoot(NextComponentPage, Parameters).then(()=>
    {
        this.events.publish("user:created", userdetails);
    });
    

提交回复
热议问题