Date-picker date format and datepicker options

1.6k views Asked by At

i have a few problems with the date-picker, especially regard the date format. I need to make a date-format like that 'ddMMyyyy' without symbols like slash or minus. this is my Markup

HTML

<input type="text" datepicker-popup="{{format}}" show-weeks="false" ng-model="Fromdate" show-button-bar='false'>

and that's my format in javascript

JS

  $scope.format='ddMMyyyy';

is this the right way to make the format? Because if i choose the date from the datepicker nothing seems to go wrong but if i type directly the text a errors happens.
the first four number were evaluated like year, so if i type '01022014' i aspect first february 2014 instead the date-picker evaluate 14 of no month (20 is not a month) of the 0102 year. Second question, i'd like to put the option of the date Picker in the js file and not in the markup, for example:

HTML

<input type="text" datepicker-popup="{{format}}" ng-model="Fromdate" datepicker-options="options">

js

$scope.options={
    show-weeks:"false"
    show-button-bar:'false'
}

but in that way it seems doesn't work, what is thee right way to do that?

1

There are 1 answers

0
Jayashree On

Use Uib-Datepicker Js:

$scope.dateOptions = {
        showWeeks: false,
        format: 'ddMMyyyy'
    };

HTML:

 <uib-datepicker ng-model="selectedDate" datepicker-options="dateOptions" ng-required="true"></uib-datepicker>