Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
This repository was archived by the owner on May 28, 2019. It is now read-only.

Prevent jquery datepicker formatDate exception #48

@candreoliveira

Description

@candreoliveira

In my point of view, you must catch the exception in your uiDateFormat directive to prevent the dowdy console error:

TypeError: Object 123 has no method 'getFullYear'

The error occurs when you type a malformed string in the input where you apply the ui-date.

Your directive try to execute (https://github.com/angular-ui/ui-date/blob/master/src/date.js#L99):

jQuery.datepicker.formatDate(dateFormat, value);

But I think you must execute:

modelCtrl.$parsers.push(function(value){
  try{
    if (value)
      return jQuery.datepicker.formatDate(dateFormat, value);                  
  } catch(err) {}
  return null;
});

Give permission to PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions