jquery - Angular2 - Binding of datepicker -
how chosen date of input , put tag <p>
.
i'm using jqueryui datepicker, tried binding trying capture change , click events, did not work.
can me?
import "rxjs/rx"; import {component, afterviewinit} '@angular/core'; declare var $: any; @component({ selector: '<my-evento></my-evento>', template: `<input (change)="updatedate($event)" type="text" id="datepicker"> <p>{{ date }}</p>` }) export class eventocomponent implements afterviewinit{ date: string; constructor(){} ngafterviewinit() { $(function() { $("#datepicker").datepicker(); }); } updatedate($event): void { this.date = $event.target.value; } }
when bind model this:
<input [(ngmodel)]="date" type="date" id="datepicker">
does compiler tell format has in yyyy-dd-mm format?
if so, may need use custom directive or bind date field date pipe this:
<input [ngmodel]="date | date:'y-mm-dd'" (ngmodelchange)="date=$event" type="date" id="datepicker">
Comments
Post a Comment