自从我将项目更新为
"angular-bootstrap": "~1.2.4"
后,我在控制台中收到警告:
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 文档 中仍然显示了
deprecated
处理这种情况的方法。
有谁知道如何迁移到新版本吗?
他们没有弃用“uib-datepicker-popup”属性,该警告与“Datepicker 设置”部分的 datepicker 文档 中列出的所有属性相关。您必须通过属性“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"
/>