Child–parent flow

In this flow, rather than passing data down, the data needs to flow up the chain. Most of the time, the data flows up based on the events triggered on the child by the user and we try to notify the parent about that event. Hence, Angular allows you to listen to the child events on the parent component and to act on the events. These events can be characterized with the data as the payload.

Let's start by registering a double-click event on each comment item via the comment list component:

<app-comment-item 
  *ngFor="let comment of comments" 
  [comment]="comment" 
  (dblclick)="showComment(comment)">
</app-comment-item>

Then, you need to add the showComment handler on the component class to handle this event:

import {  Component, ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.