-
Notifications
You must be signed in to change notification settings - Fork 204
model value not bind with datepicker #148
Comments
I have the same problem. I could not get even the example from the readme to work: ui-date-format="DD, d MM, yy" |
I've solved it. hope it will help you. ui-date-format="DD, d MM, yy" anyway the answer is already given in his documentation. so, no matter what if we are able to get convert our string date into date object then it will work. i've create another directive which will format our string date into date object. so you won't get any uncertain date selected in datepicker. Directive:
HTML:
where object[column.name] is the dynamic ng-model name. |
I have an object structure containing a date string in Finnish format (dd.mm.yy). So, ui-date's ng-model is pointing to a date as a string. "If you want to pass date strings to and from the date directive via ng-model then you must use the ui-date-format directive." From this, I got an impression that specifying ui-date-format="dd.mm.yy" allows ng-model to have strings like "01.10.2015". It is not so? I have tried something like this:
|
I am already specifying format in ui-date like this
so i have set the format from scope. instead of using ui-date-format. |
I took ui-date-format parameter away. The dateOptions look like this: If I type to the input field a date string like: "01.01.2016" The resulting ng-model object looks like: "2015-12-31T22:00:00.000Z". Also for some reason, if I have an empty string as a date the object pointed by ng-model disappears from the object structure. |
I think the ui-date-format parameter causes more confusion for some reasons:
I'll have to think on this a bit more about how to simplify this. Perhaps #127 is the way to go to keep things in synch and returning to having the date in Date or string in a valid ISO format. |
I think a consistent behavior would be that the datepicker would not change the object type from ng-model. User might have the object as a date object or as a string. If object type is string and user has specified the date format, then this format should be used on the ng-model string and on the input field. |
@sampie 👍 |
@jsmrugank thanks buddy it was awesome......working perfectly |
I am having problem with binding ng-model value with ui-date date-picker.
below screen shot is for displaying date in a particular format using this code:
{{scorecardData.mdp1.start |date:'dd/MM/yyyy'}}
While editing date :
where,
$scope.scorecardData.mdp1.start = "2015-12-17T18:30:00.000Z"
$scope.dateOptions = { //--> DATE FORMAT
changeYear: true,
changeMonth: true,
yearRange: '2015:2030',
dateFormat: 'dd-mm-yyyy'
};
I've also used ui-date-format="dd-mm-yyyy" . but it didn't work.
The text was updated successfully, but these errors were encountered: