2016-03-29 23 views
3

因为我在我的项目更新为"angular-bootstrap": "~1.2.4",我已经在控制台的警告:如何替换弃用的uib-datepicker-popup?

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由日期格式填充或日期格式的数组:

  • uib-datepicker-popup="dd-MMMM-yyyy"在我的情况

所以在angular bootstrap documentation它仍然显示deprecated的方式来处理这种情况。

有谁知道如何迁移到新版本?

回答

4

他们不会被弃用属性“UIB-日期选择器,弹出”警告是关系到节“日期选择器设置”中列出的datepicker docs所有属性。您必须通过属性“datepicker-options”来提供这些值。 不知道为什么,但“弹出设置”部分中的内容不会引发警告。

在我来说,我有

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" 
    /> 

,并成为

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" 
    /> 


更新

plunker reproduction

+0

它是'uib-datepicker-popup =“dd-MMMM-yyyy”'这给了我一个警告,没有别的 – mickro

+1

我有同样的问题。你是否检查过,如果你删除了“dd-MMMM-yyyy”这个值并且你只保存了'uib-datepicker-popup',警告仍然会被解雇? – McGiogen

+0

在plunker上新增了一个例子,尝试对最后一个日期选择器进行注释/取消注释,以确定它是具有uib-datepicker-popup没有任何值的警告的源,而第一个datepicker不会触发任何警告。 – McGiogen

相关问题