Javascript 由于添加了两个脚本,因此显示了两个日历
我在代码中使用datepicker。我最初使用的datepicker来自 现在我用它在我的页面上分页。因此,在代码中添加第二个脚本之后,页面将显示两个日历,其中我只想使用从第一个脚本加载的日历。如何删除页面上出现的第二个日历 还有一件事,我添加了如下分页脚本:Javascript 由于添加了两个脚本,因此显示了两个日历,javascript,jquery,angularjs,twitter-bootstrap,calendar,Javascript,Jquery,Angularjs,Twitter Bootstrap,Calendar,我在代码中使用datepicker。我最初使用的datepicker来自 现在我用它在我的页面上分页。因此,在代码中添加第二个脚本之后,页面将显示两个日历,其中我只想使用从第一个脚本加载的日历。如何删除页面上出现的第二个日历 还有一件事,我添加了如下分页脚本: var todoApp = angular.module('todoController', ['ui.bootstrap']); 使用ui.bootstrap,然后向其中添加datepicker指令。这是它给我看两个日历的
var todoApp = angular.module('todoController', ['ui.bootstrap']);
使用ui.bootstrap,然后向其中添加datepicker指令。这是它给我看两个日历的主要原因。但我无法摆脱它 使用引导日期选择器,输入类型应设置为文本。如果您将输入类型设置为date,它也将显示本机日期选择器。将输入类型更改为文本,然后重试。我的页面上出现的两个日历是由于控制器文件中包含的指令造成的。我使用
datepicker
作为ui引导程序以及我自己的指令都使用的指令
<input type="text" class="form-control input-lg text-center datepicker" ng-model="formData.endDate" placeholder="Choose end date" datepicker/>
todoApp.directive("datepicker", function () {
return {
restrict: "A",
require: "ngModel",
link: function (scope, elem, attrs, ngModelCtrl) {
var updateModel = function (dateText) {
scope.$apply(function () {
ngModelCtrl.$setViewValue(dateText);
});
};
var options = {
dateFormat: "yy-mm-dd",
onSelect: function (dateText) {
updateModel(dateText);
},
minDate: -0
// maxDate: "+1M +10D"
};
elem.datepicker(options);
}
}
});
我没有使用
datepicker
作为指令的名称,而是使用mydatepicker
。因此,冲突得以解决。您是否仍包括?是的,我需要jquery链接中的日期选择器。而不是引导式的。
<input type="text" class="form-control input-lg text-center datepicker" ng-model="formData.endDate" placeholder="Choose end date" mydatepicker/>
todoApp.directive("mydatepicker", function () {
return {
restrict: "A",
require: "ngModel",
link: function (scope, elem, attrs, ngModelCtrl) {
var updateModel = function (dateText) {
scope.$apply(function () {
ngModelCtrl.$setViewValue(dateText);
});
};
var options = {
dateFormat: "yy-mm-dd",
onSelect: function (dateText) {
updateModel(dateText);
},
minDate: -0
// maxDate: "+1M +10D"
};
elem.datepicker(options);
}
}
});