I am trying to call a method from child component in parent component because I have this html code for parent
<div class="right view-calendar">
<child *ngFor="let selectedMonth of selectedMonths" [viewDate]="selectedMonth" [monthList]="show()"></child>
</div>
parent component:
export class ParentComponent implements OnInit {
@ViewChildren(MonthHeaderComponent) months: any[];
show() {
this.months.method();
}
}
child component
export class ChildComponent implements OnInit {
@Input() monthsList: Date[]
method() {
// code here....
}
}
I've read this issue Can't get to @ViewChildren in parent component but I don't know if there's something that can help me.
What am I doing wrong here?