How to pass data from a child component to app-root component.

11 views
Skip to first unread message

Rajashree Behera

unread,
Jul 24, 2019, 12:56:01 PM7/24/19
to Angular and AngularJS discussion
Requirement:
I need to get a data/flag status from child component to app component. This flag value changes if some operation is done, accordingly the changed flag value must be passed to app.component without page load.

I am trying to pass data from child component to app-root component.
@Input cannot be used as app-root is a Bootstrapped component and its available in index.html.

Sander Elias

unread,
Jul 24, 2019, 1:03:32 PM7/24/19
to Angular and AngularJS discussion
Hi Rajashree,

Use @Output on your child, and use a method in your app-component to pick up this change.

Regards
Sander

Rajashree Behera

unread,
Jul 25, 2019, 2:41:38 AM7/25/19
to ang...@googlegroups.com
Hi Sander,

I used @Output in my child component, but app-root is there in index.html

How am i supposed to pass data in this case as @Output is not working.

Thanks
Rajashree

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/1012601e-2cda-4814-83cc-f24b9898f098%40googlegroups.com.

Sander Elias

unread,
Jul 25, 2019, 11:58:15 AM7/25/19
to Angular and AngularJS discussion
Hi Rajsashree,

So you want to send data to the outside of the application? If that is the case, you need to have it emit a custom DOM event.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages