Doubts about emit and receiving events (Js)

Hello, i started using the framework recently and i would like to know how to emit and receive events. The same as in the vue we use $ emit to send and @name to receive.

Like the example in Component, we have bound the button with $emit name is hello-world.

$emit('hello-world')

then when we input that child component into the main component by the name:

@hello-world="helloworld()"

then use methods or setup() to make logic in your app.
I hope this answerable helps u. I don’t know do you have any questions?

if you wanna bind the API in your child component with outside the main component got <card item $event />

you re just do like how the generate vue framework does for. Cuz Ionic just is a component UI tool to help you make a better looked like mobile views.

EX:
in the main component, we bind the child component like:
<Card :item="item" @hello-world="ViewItem($event)" />

so in Child Card Component, you must have **props ** of an item, then you are able in the main components on methods to make logic like:

methods: {
  viewItem(item) {
       this.item = item;
       console.log(this.item);
  }
}

In your child Card Component must have:

<ion-button @click="$emit('hello-world', item)">click</ion-button>

props: ['item']

Hope this answer can help you.

The short answer is yes you can write your own custom event just like you do in VueJs… and apart from that you can also leverage on the default events that the ion-components emit on various life-cycle stages… the list of such event can be found inside of the documentation

As an example here is the list of default events that a <ion-menu> will emit Documantation Link

thank you very much, it’s working just fine

thank you, I will seek to inform myself about the default events