0

I know that there are questions relating this topic and I took a look at the docs but I couldn't understand how to use outputs.

I have a child component with this @Output

//here I define the Ouput on the child component
@Output() turvo: EventEmitter<boolean> = new EventEmitter();

//here I emit the event on the child component
ngOnInit() {
  this.turvo.emit(false);
}

The parent component

//here I listen to the emitted event on the parent
<div (turvo)="atribuirTurvoDoFilho($event)"></div>

//here is the function that should be executed on the parent.
public atribuirTurvoDoFilho(data) {
  console.log("I will never execute :(");
  this.turvo = data;
}

I got no errors but no communication occurs.

cyr_x
  • 13,987
  • 2
  • 32
  • 46
Diego Alves
  • 2,462
  • 3
  • 32
  • 65

1 Answers1

0

If you want to have a working solution, please share your full child component.

For now, I can see, that you try to run your output on the div element - which is a html tag, not a angular component.

If you define an output, it will be working only for that component where is defined.

Piotr P.
  • 74
  • 1