The way to get the argument emitted by the event is through the keyword : $event
//(click)="edit=!edit; sauverTache(myTache);"
(click)="edit=!edit; sauverTache($event);"
If you need a parameter coming from some iterated array, you can pass it as well
<div *ngFor="let myTache of Taches">
...
<div class="btn btn-circle btn-default font-green-jungle"
*ngIf="edit" (click)="edit=!edit; sauverTache(myTache);">
<i class="fa fa-check "> </i>
</div>
...
</div>
And in case we need some kind of customization from our component class, we can also
class MyComponent {
public myTache: number;
ngOnInit() {
this.myTache = 1;
}
}
and now we can ask for this to be transmitted as in the original fragment
(click)="edit=!edit; sauverTache(myTache);
myTache ( ngFor) . - $event
- sauverTache, . EventEmitter:
sauverTacheObservable = new EventEmitter();
sauverTache(tache: Tache){
this.editionEnCours = true;
tache.estReelle = true;
// this is self calling.. and causing problem...
// this method does not have method emit
//this.sauverTache.emit(tache.id);
// but now, we call proper emitter
this.sauverTacheObservable.emit(tache.id);
console.log(tache.id);
}