Reputation: 1721
I have a component y which uses directive :
<div makeDroppable (dropped)="getDroppedList($event)">
<ul>
<li *ngFor="let task of toAddList" >{{task.id}}</li>
</ul>
</div>
at the end of directives MakeDroppable , an event is emit
let data = JSON.parse(ev.dataTransfer.getData('text'));
this.dropped.emit(data);
this event is treated by (dropped)="getDroppedList($event)" (in div) and thus calls getDroppedList of my component. in this getDroppedList méthod, another event is emit
this.toAddList = <Array<Task>>event;
console.log('emity event');
this.toto.emit(this.toAddList);
this new event toto is used in another component x where html is
<tr *ngFor="let task of tasks" (toto)="removeDroppedList($event)">
removeDroppedList is a method defined in x
removeDroppedList(event){
console.log('this second event')
when i execute code, the second event does not seem to be treated because the 'this second event' is never displayed in console. i put a breakpoint at console.log('this second event'), but it never stops
Upvotes: 0
Views: 40
Reputation: 1815
Assuming the missing " isn't relevant, is there a disconnect with the todo event? What I mean is, are there more than one todo object being created? How does component Y have reference to component X's todo event?
Seems like you need a service so both components have reference to the same event object as component X would need to have that as an output and component Y would get it's reference from the service so it can emit a value.
Upvotes: 0