O'Reilly logo

Angular 2 Cookbook by Matt Frisbie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating and capturing custom events using EventEmitter

In the wake of the disappearance of $scope, Angular was left with a void for propagating information up the component tree. This void is filled in part by custom events, and they represent the Yin to the downward data binding Yang.

Note

The code, links, and a live example of this are available at http://ngcookbook.herokuapp.com/8611/.

Getting ready

Suppose you had an Article application as follows:

[app/text-editor.component.ts] import {Component} from '@angular/core'; @Component({ selector: 'text-editor', template: ` <textarea></textarea> ` }) export class TextEditorComponent {} [app/article.component.ts] import {Component} from '@angular/core'; @Component({ selector: 'article', template: ` ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required