4

Since I updated my project to "angular-bootstrap": "~1.2.4", I've a warning in the console:

uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead

uib-datepicker-popup is filled by a date format or an array of date formats:

  • uib-datepicker-popup="dd-MMMM-yyyy" in my case

So in angular bootstrap documentation it is still shown the deprecated way to handle this case.

Does anyone know how to migrate to the new version?

qqbenq
  • 10,220
  • 4
  • 40
  • 45
mickro
  • 881
  • 2
  • 11
  • 26

2 Answers2

5

They have not deprecated the attribute "uib-datepicker-popup", the warning is related to all attributes listed in datepicker docs in section "Datepicker Settings". You have to provide those values by the attribute "datepicker-options". Don't know why but those in section "Popup Settings" are not throwing the warning.

In my case I had

JS

$scope.datepicker.format = "shortDate";
$scope.datepicker.options = {
    formatYear: "yy",
    startingDay: 1,
};

HTML

<input type="text" class="form-control" 
    ng-model="ngModel"
    uib-datepicker-popup="{{ datepicker.format }}"
    datepicker-options="datepicker.options"
    
    datepicker-append-to-body="true" 
    is-open="datepicker.opened"               
    show-button-bar="false"
    close-text="Close"
    
    min-date="minDate"
    max-date="maxDate"
    custom-class="getCustomClass"
    show-weeks="false"
    />

and it became

JS

$scope.datepicker.format = 'shortDate';
$scope.datepicker.options = {
    formatYear: 'yy',
    startingDay: 1,
    minDate: minDate,
    maxDate: maxDate,
    showWeeks: false,
    customClass: getCustomClass
};

HTML

<input type="text" class="form-control" 
    ng-model="ngModel"
    uib-datepicker-popup="{{ datepicker.format }}"
    datepicker-options="datepicker.options"

    datepicker-append-to-body="true" 
    is-open="datepicker.opened"               
    show-button-bar="false"
    close-text="Close" 
    />

Update ==========

plunker reproduction

CJ Dennis
  • 4,226
  • 2
  • 40
  • 69
McGiogen
  • 654
  • 8
  • 17
  • it is `uib-datepicker-popup="dd-MMMM-yyyy"` which gave me a warning, nothing else – mickro Mar 31 '16 at 13:48
  • 1
    I had the same issue. Have you checked if the warning is still fired if you remove the value `"dd-MMMM-yyyy"` and you keep only `uib-datepicker-popup`? – McGiogen Apr 01 '16 at 07:01
  • Added example on plunker, try to comment/uncomment the last datepicker to see that it is the source of the warning having uib-datepicker-popup without any value while the first datepicker doesn't fire any warning. – McGiogen Apr 01 '16 at 14:51
  • @McGiogen what is the use of having formatYear: 'yy', in dateoptions? – H Varma Dec 27 '16 at 10:01
  • As you can see in the [datepicker documentation](https://angular-ui.github.io/bootstrap/#/datepicker), `formatYear: 'yy'` changes the format of year in year range from yyyy (ex.: 1990-1995) to yy (ex.: 90-95). In this answer it is only an example of configuration. – McGiogen Dec 28 '16 at 11:43
1

Here is the upgrade guide. It works well to me. https://github.com/angular-ui/bootstrap/wiki/Migration-guide-for-prefixes

nolines
  • 150
  • 1
  • 15
  • Thanks I did not reminded this doc. However it says: `Change: datepicker-popup for uib-datepicker-popup.`. But `uib-datepicker-popup` is exactly what will be depreciated... – mickro Mar 29 '16 at 13:26