I have a simple component with a template consisted of two date pickers and a selector named 'app-date-adapter'
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date"
#fromDate>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
<mat-form-field>
<input matInput [matDatepicker]="picker2" placeholder="Choose a date"
#toDate>
<mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker #picker2></mat-datepicker>
</mat-form-field>
this component has a selector and i included the selector inside another component template (which i call parent), that has this button
<app-date-adapter ></app-date-adapter>
<button class="btn-primary" type="button" class="btn btn-info" (click)="dateRange(fromDate.value, toDate.value)">Filter My Date</button>
It doesn't work and it cannot identify fromDate and toDate elements, where as if i put them all together in one template then it works. Do I really need event binding and all of that for getting those input values from the child template?! There is no simpler way than that?