以下是我的datepicker指令
app.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: "dd-mm-yy",
onSelect: function (dateText) {
updateModel(dateText);
}
};
elem.datepicker(options);
}
}
});
我需要在文本框中将默认值作为当前日期(dd-mm-yy)。请帮帮我
答案 0 :(得分:0)
将defaultDate
添加到选项
var options = {
dateFormat: "dd-mm-yy",
onSelect: function (dateText) {
updateModel(dateText);
}
};
elem.datepicker(options).datepicker("setDate", new Date());
updateModel(elem.val())