Pasteur Miranda
Posts: 0
Joined: Thu Aug 01, 2013 2:59 am

How to format a date field

Hi,

I have a date field that is retrieved by a rest service and is of type date. This field is retrieved to a scope variable that has the format yyyy-mm-dd . It is shown in a input field of type date, format dd-mm-yyyy. The scope variable is placed in ng-model directive of the input field. But when the value is retrieved I receive the error message "Error: [ngModel:datefmt] ". I think it's a date format error. How can i solve it?

Code: Select all

Thanks.
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to format a date field

Hello,

Please use Date variables in the component input with type=date.
E.g. you can add on service response JS:
pre$scope.myDate = new Date(newValue);/pre
here myDate - name of the variable, which you use in the date component
newValue - service responce with date value

Pasteur Miranda
Posts: 0
Joined: Thu Aug 01, 2013 2:59 am

How to format a date field

Thanks Sergiy, it worked!

Return to “Issues”