kekeh / angular-mydatepicker

Angular datepicker and date range picker :date:
https://kekeh.github.io/angular-mydatepicker/
MIT License
1 stars 11 forks source link

required directive is no work #28

Closed coloz closed 4 years ago

coloz commented 4 years ago

in ngForm,add required directive, the mydatepicker always shows ng-invalid class

            <input class="date-input" placeholder="点击选择时间" angular-mydatepicker name="date"
                (click)="dp.toggleCalendar()" [locale]="'zh-cn'" [(ngModel)]="date" [options]="myDpOptions"
                #dp="angular-mydatepicker" (dateChanged)="onDateChanged($event)" required />
kekeh commented 4 years ago

I tested with this https://github.com/kekeh/angular-mydatepicker/tree/master/example/app/date-picker-ngmodel component and it worked ok. That component belongs to the example application.

No date selected => ng-invalid invalid

Date selected => ng-valid valid

Here https://github.com/kekeh/angular-mydatepicker#development-of-this-component are instructions on how to run test application.

Before run the application add the required attribute to this line https://github.com/kekeh/angular-mydatepicker/blob/master/example/app/date-picker-ngmodel/date-picker-ngmodel.html#L271

Then you can test the case.