Using ngx-bootstrap Datepicker in an Angular 4 app,
I know that usually you can specify the date format as follows:
<input id="from" name="from"
bsDatepicker [(bsValue)]="myModel"
value="{{ myModel | date:'yyyy-MM-dd'}}">
but this time I ended up in an Angular form with a template, so my input is not bound to a type variable myModelin the above example, but it is just bound to the form:
<input id="from" name="from"
bsDatepicker ngModel>
so how can i specify the date format in this case?
Edit : it looks like you can create a new variable newVarinside the component and then bind it to [(bsValue)]="newVar":
<input id="from" name="from"
bsDatepicker ngModel
[(bsValue)]="newVar"
value="{{ newVar | date:'yyyy-MM-dd' }}">
However, I am wondering if there is a better solution.
source
share