There is a nice discussion on the Angular2 issue tracker about: "Why EventEmitter doesn't bubble up ?". This discussion is here.
So I think that you have to expose the event in the whole hierarchy of components...
I propose the following solution :
Dashboard.ts :
import {Component} from 'angular2/core';
import {MyTicker} from './my-ticker'
@Component({
selector: 'dashboard-app',
template: `<my-ticker [datas]="dashBoardDatas" (onSelection)="selectValueChanged($event)"></my-ticker>`,
directives: [MyTicker],
})
export class DashboardApp {
private dashBoardDatas: Array<string>;
constructor(){
this.dashBoardDatas = ["toto", "tata"];
}
selectValueChanged(value: string){
console.log('Selected value changed to :' + value);
}
}
And MyTicker.ts :
import {Component, Input, Output, EventEmitter, AfterViewInit} from 'angular2/core';
import {MySelect} from './my-select'
@Component({
selector: 'my-ticker',
template: `
<p>
<my-select [datas]="datas" (onSelection)="onSelection.emit($event)"></my-select>
</p>
`,
directives: [MySelect]
})
export class MyTicker {
@Input() datas: Array<string>;
@Output() onSelection: EventEmitter < string > = new EventEmitter();
constructor() {}
ngAfterViewInit(){
console.log("Datas in ticker : " + this.datas);
}
}
And MySelect.ts :
import {Component, Input, Output, EventEmitter} from 'angular2/core';
@Component({
selector: 'my-select',
template: `
<p>
<select name="filter" (change)="onSelection.emit($event.target.value)">
<option *ngFor="#item of datas" value="{{item}}">{{item}}</option>
</select>
</p>
`
})
export class MySelect {
@Input() datas: Array<string>;
@Output() onSelection: EventEmitter < string > = new EventEmitter();
constructor() {}
}
I did the following Plunkr to illustrate this.
As you can see, in the Dashboard, I have a method that I want to trigger when the content of the ticker's select change (selectValueChanged) (that is triggered when my-select selection change)... So we have to re-define the event emitter in "MyTicker".
The ticker and select contains the same members as in you question. An event emitter, and the filter's datas. When the select value change, I emit the event (thanks to (change)="onSelection.emit($event.target.value)" ).
This event is "catched" by the ticker and re-emited, and then catched by dashboard (thanks to "(onSelection)="selectValueChanged($event)". So the method "selectValueChanged" of Dashboard is called when the event "OnSelection" of MySelect is fired.