If I have a component like
@Component({selector: 'todo-cmp'})
class TodoCmp {
@Input() model;
@Output() complete = new EventEmitter();
onCompletedButton() {
this.complete.next();
}
}
and in another component I get a copy of it through DI, as in:
...
class SomeOtherClass(){
constructor(todoCmp:TodoCmp){
// how do I listen to
...
}
...
How to add an event listener manually inside "SomeOtherClass" and listen to any click events fired from the instance entered in Dependendcy ToDoCmp ..
something like todoCmp.addEventListener ('complete', function (e) {});
may be? or is something better in ng2?
TX
Sean.
source
share