Open miguel-leon opened 8 years ago
One could define a directive with negative priority and reorder it.
But I'm wary of changing the order of the formatters - this would most definitely mean we need to rewrite the formatter completely due to the different states of the value, and certainly be a breaking change for users who are modifying the formatters/parsers.
-1 to this request on first glance, I need a lot more information to be convinced.
Hi, There's no priority reordering of existing directives as for example ngModel! It seems only logical to me that formatting to the desired date format should be the last thing to be done. No need to give me -1s as you put it just because you're not convinced.
Here, http://plnkr.co/edit/dtrBkd8lcz7EMUV4LYGF, more information as you requested.
The code just harnesses what has been made already with angular ngModel input[date]
and with UI Bootstrap to have date inputs with Date object models but at the same time have a locale custom format.
I had to manually change the position of the uib-datepicker formatter at line 16 with:
// Reorder uib-datepicker formatter
ngModel.$formatters.unshift(ngModel.$formatters.pop());
It gets only worst when working with multiple directives that also add formatters.
Finally you might think, there's no need to use ngModel, uib-datepicker already does the job of having Date object models. But that is not the point, and one might still want to achieve this with datepickers in some inputs and without them in others, and it should work in all cases, just by adding the final formatter if the datepicker directive is missing.
The
uibDatepickerPopup
ngModel
formatter is being pushed instead of unshiftted. The way it is right now, doesn't leave room to work with other directives, asuibDatepickerPopup
ispriority 0
, this formatter is always going to be the first one to execute instead of the last.Please change at least line 690 of datepicker.js from
to
(There's nothing to reproduce using http://plnkr.co/)