Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49246

Ionic 4 How to get component instance from modal (workaround?)

$
0
0

@M4rt1n wrote:

Hy Guys!
I have same problem described here:

this may be a workaround? (seems work fine in my app)

    let eventEmitter= new EventEmitter();
    eventEmitter.subscribe(res=>{
      console.log("emitterResult", res)
    });

      const modal = await this.modalCtrl.create({
      component: MyComponent,
      componentProps: {
        clickFavorite: eventEmitter
      }
    });

   await modal.present()
export class MyComponent  {
  @Output() clickFavorite= new EventEmitter<any>();

  favorite(evt){
      this.clickFavorite.emit("OK");
  }
}
<ion-card color="primary" >
      <div class="ion-text-end" (click)="favorite($event)">
                    blabla
      </div>
</ion-card>

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>