How do you get the data out of a materialize datepicker?
I am trying to use Angular 2
data binding to get the data and it is not working.
My binding to startDate
is never called and it never changes, it stays undefined.
DateStuff.html
<form action="#">
<div class="input-field">
<input id="date_picker" type="date" class="datepicker" [(ngModel)]="startDate">
<label for="date_picker">Start Date</label>
</div>
</form>
DateStuff.ts
@Component({
selector: "date-stuff",
templateUrl: "./DateStuff.html"
})
export class DateStuff {
private _startDate: string;
public ngAfterViewInit(): void {
$(".datepicker").pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year
});
}
public get startDate(): string {
return this._startDate;
}
public set startDate(value: string) {
this._startDate = value;
}
}
Aucun commentaire:
Enregistrer un commentaire