I have two datepickers(Start Date and End Date) in a loop. I would like to close startdate datepickers when trying to open enddate and vice versa. I have tried giving different references to input (#start, #close)
<div class="input-group" *ngIf="item.id =='startDate'">
<input class="form-control" placeholder="{{item.placeholder}}"
name="dp" [(ngModel)]="item.dateModel" ngbDatepicker #start="ngbDatepicker">
<button class="input-group-addon" (click)="start.toggle();end.close()" type="button">
<img src="img/calendar-icon.svg" style="width: 1.2rem; height: 1rem; cursor: pointer;"/>
</button>
</div>
<div class="input-group" *ngIf="item.id =='endDate'">
<input class="form-control" placeholder="{{item.placeholder}}"
name="dp" [(ngModel)]="item.dateModel" ngbDatepicker #end="ngbDatepicker">
<button class="input-group-addon" (click)="end.toggle();start.close()" type="button">
<img src="img/calendar-icon.svg" style="width: 1.2rem; height: 1rem; cursor: pointer;"/>
</button>
</div>
If i remove *ngIf from input-group and give to its parent it works but both of them having same dates. Note: Currently i cannot change input data model. Here is the plunker which mocks my use case http://plnkr.co/edit/ukbt33q7e1uyNNbPh2cN?p=preview