This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$overrideModelOptions does not apply timezone #16181
Milestone
Comments
You are right, it is a bug (or at least, I believe it is unintended behavior). The reason this happens is that in "date-family" directives, we cache the timezone in the directive's pre-linking phase, which comes before your I think we shouldn't cache that value (or at least not until later). In the meantime, you can ensure your call happens before caching the timezone, by moving it in the pre-linking phase and giving your directive a higher-than-default priority: return {
priority: 10,
...
link: {
pre: function ($scope, element, attrs, ngModel) {
ngModel.$overrideModelOptions({...});
}
}
}; |
Yes, thank. Now i use this solution pre: (scope, element, attrs, ngModelCtrl) => {
ngModelCtrl.$overrideModelOptions({
timezone: 'utc'
})
ngModelCtrl.$parsers.push((value) => {
let utc = moment.utc(value);
let serverTimeZone = 'Europe/London'; // for example
let tzOffsetMinutes = moment.tz(utc, serverTimeZone).utcOffset();
let serverLocalDate = utc.subtract(tzOffsetMinutes, 'minutes');
return serverLocalDate.toDate();
})
} |
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Nov 21, 2017
This commit also fixes a bug where part of the Date object was re-used even after the input was emptied. Fixes angular#13382 Closes angular#16181
3 tasks
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Nov 21, 2017
This commit also fixes a bug where part of the Date object was re-used even after the input was emptied. Fixes angular#16181 Closes angular#13382
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Dec 13, 2017
This commit also fixes a bug where part of the Date object was re-used even after the input was emptied. Fixes angular#16181 Closes angular#13382
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Apr 6, 2018
This commit also fixes a bug where part of the Date object was re-used even after the input was emptied. Fixes angular#16181 Closes angular#13382
This was referenced Apr 18, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm thinking is bug
Current behavior:
Changing timezone programmatically (use $overrideModelOptions) dont work
Expected / new behavior:
If we set new timezone, it apply to model
Minimal reproduction of the problem with instructions:
Plunker: http://plnkr.co/edit/7zHR1EKigTMaFjDU1yDc?p=preview
Angular version - 1.6.5
The text was updated successfully, but these errors were encountered: