I am getting a date time value from asp.net mvc controller as \"2014-08-31T00:00:00Z\". When I bind this value to my angular-ui datepicker control it\'s state is showing as ng-i
A couple of notes here:
datepicker
directive requires that the ng-model
be a Date
object. This is documented here.Date
object if it matches a hard-coded pattern. This is not flexible nor is it easily testable. It will not be the right solution for most people.If, in your system, global date string conversion is the right behavior, the proper Angular design would be to create a service that does this for you. This leads me to...
We've (Angular UI Bootstrap) provided a mechanism for converting date strings into Date
objects via the dateParser
service. You can see the source code here. NB: this service name becomes deprecated and changed to uibDateParser
with the 0.14.0 release.