I'm trying to emit an array to a parent component, however I keep getting undefined when I try with console.log for the emitted data, my other event emitter is working fine, Event two is emitting the array but when output in the console gives me undefined(only code that's necessary is shown).
child component ts file:
@Output() eventTwo: EventEmitter<any> = new EventEmitter<any>();
// the emitting function (fillArray is the array I'm trying to send)
sendNo () {
this.event.emit({columns: this.height, rows: this.width});
this.eventTwo.emit(this.fillArray);
}
child component html file:
<label>Width: </label><input type="number" [(ngModel)]="height"
(ngModelChange)="sendNo()" (ngModelChange) = "getRnd()">
<p></p>
<label>Height: </label><input type="number" [(ngModel)]="width"
(ngModelChange)="sendNo()" (ngModelChange) = "getRnd()" >
<p></p>
parent component html file:
<app-inputs (event)="getDataFromChild($event)"
(eventTwo)="getDataFromChildTwo($eventTwo)"></app-inputs>
parent component ts file:
getDataFromChildTwo(data) {
this.randVal = data;
console.log(this.randVal);
}
$event
not$eventTwo
like this:<app-inputs (event)="getDataFromChild($event)" (eventTwo)="getDataFromChildTwo($event)"></app-inputs>
– Sanoj_V