How do I get the chosen date of input and put the tag <p>.
I'm using the jqueryUI datepicker, already I tried to do the binding trying to capture with the change and click events, but did not work.
Can anybody help me?
import "rxjs/Rx";
import {Component, AfterViewInit} from '@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;
}
}
<input [(ngModel)]="date" type="text" id="datepicker">but when I use the calendar does not do the bindingmarkForCheckordetectChangesto trigger an update. Also have a look at theDoChecklifecycle hook angular.io/docs/ts/latest/guide/lifecycle-hooks.html#!#docheck which is where you'd make your calls on theChangeDetectorRefexport class EventoComponent implements AfterViewInit, DoCheck{ constructor(private _cdr: ChangeDetectorRef) {} ngDoCheck() { this._cdr.detectChanges(); } }