0

I am using ngbDateTimePicker in my code and trying to get the value on change but I am not able to get it. I am trying click, ngmodelchange but nothing is working can anybody suggest me how to do this, please.

Below is my code

<div class="input-group" *ngSwitchCase="'date'" [attr.for]="dynamic.key" >
   <input class="form-control" [type]="'text'" placeholder="dd/mm/yyyy" [minDate]="minDate" [maxDate]="maxDate" ngbDatepicker #d1="ngbDatepicker"  ngModel   [attr.data-required]="dynamic.required"  [attr.for]="dynamic.key" [formControlName]="dynamic.fieldName" [id]="dynamic.fieldName" [name]="dynamic.fieldName" [attr.data-validation]="dynamic.validation" (click)="checkValidation(dynamic.fieldName,dynamic.validation,dynamic.required,dynamic.label);"  (blur)="checkValidation(dynamic.fieldName,dynamic.validation,dynamic.required,dynamic.label);" >
 <div class="input-group-addon" (click)="d1.toggle()">
       <i class="fa fa-calendar" aria-hidden="true"></i>
   </div>
</div>
2
  • Please check out here stackoverflow.com/questions/38227838/… Commented Apr 26, 2018 at 6:27
  • @ Anand Choudhary I am looking for ngbDatepicker's event that link above you mentioned is not related to it. I can't use any events on it. Commented Apr 26, 2018 at 6:32

1 Answer 1

0

Men, your 'ngModelChange' works when you are simple using ngModel approach. When I want to use masked inputs to add "/", I need to implement my own ControlValueAccessor, that's fail at all.
Just a EventEmitter output property in ngb-datepicker, that can allow us to subscribe changes (like, 'valueChanges' of forms), it will help us a lot!

Sign up to request clarification or add additional context in comments.

2 Comments

please suggest me some sober datepicker on angular2 which has events withpout ngmodel
As @raghav suggests, you cannot access the datepicker model from your controller because the datepicker has its own private scope. for more info checkout link below stackoverflow.com/questions/19316937/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.