Using ngx-bootstrap Datepicker in an Angular 4 application,
I know that normally you can specify the date format this way:
<input id="from" name="from"
bsDatepicker [(bsValue)]="myModel"
value="{{ myModel | date:'yyyy-MM-dd'}}">
but this time I'm inside a template-driven Angular form, so my input is not bound to a variable like myModel
in the example above, but it's 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 that a way to achieve this is by creating a new variable newVar
inside the component and then binding it with [(bsValue)]="newVar"
:
<input id="from" name="from"
bsDatepicker ngModel
[(bsValue)]="newVar"
value="{{ newVar | date:'yyyy-MM-dd' }}">
However I wonder if there is a better solution.