In DateRangeComponent
I'm trying to emit array on button click to another (ViewerComponent
) component using EventEmitter
and Output
decorator.
There is a getData()
method in DateRangeComponent
where EventEmitter
emit an array from service.
@Output() dataEmitter = new EventEmitter<any[]>();
constructor(private dataService: DataService) { }
getData() {
let fromDate = this.dateName[0];
let toDate = this.dateName[1];
this.dataService.findNameByDate(fromDate, toDate)
.map(names => {
this.names = names;
this.dataEmitter.emit(this.names);
//console.log(JSON.stringify(this.names));
}
)
}
Component should receive emitted array using Input
decorator:
@Input() names: any;
and there is a property binding in HTML:
<app-table *ngIf="selectedDate" [names]="names"></app-table>
but there is a problem with receiving. What's wrong?