0

I have header and body in my Angular components.

Have a notification count in the header and would like to update the count whenever the count gets changed by user in the body.

app.routing.ts

export const AppRountes: Routes = [{
   component: LayoutComponent,
   children: [
    {
     path: 'notification',
     loadChildrent: './notification/notification.module#NotificationModule'
    }
   ]
  }]

I have a NotificationComponent for notification.

The notification icon and the count is there in the LayoutComponent.

Here, I would like to notify from NotificationComponent to LayoutComponent.

I am able to communicate from LayoutComponent to NotificationComponent using @ViewChild, but not sure how to communicate from child to parent.

halfer
  • 19,824
  • 17
  • 99
  • 186
user1578872
  • 7,808
  • 29
  • 108
  • 206

1 Answers1

2

Normally, you would use an EventEmitterplus @Output, since you're using the router you cannot really do this. I think you can find an answer here though: Angular 2 output from router-outlet

Christian S.
  • 295
  • 1
  • 2
  • 12