Outputs

Outputs allow components to emit custom events. For example, if we have a component that displays a button and we want the parent component to be able to add an event handler for the click event of the child component, we can achieve this using outputs.

Here is an example of how to integrate outputs. Place this code above the App component's code:

var SampleComponent10 = ng.core.Component({ selector: "sampleten", outputs: ["click"], template: "" }).Class({ constructor: function(){ this.click = new ng.core.EventEmitter(); setInterval(function(){ this.click.next({}); }.bind(this), 10000) } }) var SampleComponent11 = ng.core.Component({ selector: "sampleeleven", directives: [SampleComponent10], template: "<br><sampleten (click)='clicked($event)'></sampleten>{{value}}" ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.