angular 2 ng-bootstrap datepicker popup

人走茶凉 提交于 2019-12-04 05:57:00

I tried to change the #d to #d1 and #d2 (also chancge the toggle() part) and the page spits out errors.

There must be something specific to your application going on since this is the right approach. A working code snippet:

 <div class="input-group">
        <input class="form-control" placeholder="yyyy-mm-dd" name="dp1" [(ngModel)]="newItem.EndTime"  ngbDatepicker #d1="ngbDatepicker" required>
        <div class="input-group-addon" (click)="d1.toggle()" >
            <i class="fa fa-calendar" aria-hidden="true"></i>
        </div>
    </div>

    <div class="input-group">
        <input class="form-control" placeholder="yyyy-mm-dd" name="dp2" [(ngModel)]="newItem.StartTime"  ngbDatepicker #d2="ngbDatepicker" required>
        <div class="input-group-addon" (click)="d2.toggle()" >
            <i class="fa fa-calendar" aria-hidden="true"></i>
        </div>
    </div>

And the live example in plunker: https://plnkr.co/edit/ZC3dOX9anbbNUMPEEd5W?p=preview

Verify that you've got unique input names and that you use unique variable names pointing to a directive instance (#d1, #d2 etc.). If you still face problems reproduce it in the plunker I've linked and open an issue in https://github.com/ng-bootstrap/ng-bootstrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!