The angular Ionic child component passes data to the parent component.

I want to get the information in the subcomponent, but I don"t know why I can"t get the data

this is the subcomponent ts file
clipboard.png

clipboard.png

html

clipboard.png

Why can"t I get the data in the subcomponent


because your getData method is not triggered on your custom component, of course you can't write this method on ion-content .


it seems that there is nothing wrong with the code. In fact, you should not get data on ion-content. If you want to use child components, you can import directly in the parent component ts

.
import child from ../childCom.ts

then directly in the parent component html

<child (event)="getData($event)"></child>

it is recommended to change getData (msg:string) to getData (msg:event) or getData (msg)

Menu