Page 1 of 1

How to format a date field

Posted: Mon Mar 07, 2016 1:24 pm
by Pasteur Miranda

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.

How to format a date field

Posted: Mon Mar 07, 2016 6:15 pm
by Serhii Kulibaba

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


How to format a date field

Posted: Tue Mar 08, 2016 1:39 am
by Pasteur Miranda

Thanks Sergiy, it worked!