Hi I am upgrading an application to angular 2. I am creating a new datepicker component, wrapping a vanilla javascript datepicker (pikaday) The component looks great, but when I select a date, I can't see those changes in my angular model.
constructor(myInput: ElementRef) {
let opts = {
field: myInput.nativeElement,
format: 'YYYY-MM-DD',
onSelect: () => {
this.value = this.datePicker.getMoment().format(this.dateFormat);
}
};
this.datePicker = new Pikaday(opts);
}
<!---- template --->
<div class="cad-date-picker field">
<label class="field__in el-w100">
<input class="input" value="{{value}}" readOnly/>
<div class="field__icon">
<cad-icon name="calendar"></cad-icon>
</div>
</label>
</div>
----------------------------------------
<!---- Page --->
<div class="field">
<label class="field__in el-w100">
<input class="input" name="startDate" cad-date-time-picker="vm.startDateOptions" ng-required="vm.isSubmitting" ng-model="vm.rfp.startDate" ng-model-options="{allowInvalid: false}" ng-change="vm.dateChange('startDate')"/>
<div class="field__icon">
<cad-icon name="calendar"></cad-icon>
</div>
</label>
</div>
<cad-date-picker [(value)]="vm.rfp.startDate"></cad-date-picker>
In am testing with the two components, the up component is angular 1, the down component is angular 2.
I already tried to do this post, but it does not work