Open CesarD opened 6 years ago
@CesarD I had the same problem that you described, and my workaround was a directive that treats the bug. Here is what the directive looks like:
.directive("undefinedDate", () => {
return {
restrict: 'A',
required: 'ngModel',
link: (scope, element,attr, ngModel) => {
const inputModelCtrl =element.controller("ngModel");
inputModelCtrl.$parsers.push(value => {
if (value === true || value == "") {
return undefined;
}
return value;
})
}
}
});
And the input:
<input undefined-date ng-model="$ctrl.myDateModel" moment-picker="$ctrl.myDateModel" format="MM/DD/YYYY">
I hope this helps you.
Yes, that's the same I ended up doing. It's just a workaround, but not for avoiding it but for patching it up... Would be useful to know if there's anything to do to prevent it from start or if it can be fixed at all from the library.
Any update on this bug?
I don't think this will ever get fixed... Most likely project is abandoned. Probably best to take the jump onto Angular 7+
I have my control with a validator directive, and in the validator code:
ctrl.$validators.validator1 = function (modelValue, viewValue) { ...... }
When I delete the date from the input,
modelValue
returns the booleantrue
, instead of a null value or empty object.Is this supposed to happen? Any workaround to avoid it? Thanks.