我創建了jQuery-UI datepicker的angularjs指令,我在formj中使用它,但卡在驗證部分。我使用這個指令在我和我需要驗證日期不超過日期的日期,我發佈我的指令代碼以供參考。請糾正我關於要完成的驗證。需要幫助來驗證角jquery UI datepicker指令
app.directive("datePicker", function() {
return {
restrict: "A",
require: "ngModel",
link: function (scope, elem, attrs, ngModel) {
var updateModel = function (dateText) {
ngModel.$render = function() {
scope.$apply(function() {
ngModel.$setViewValue(dateText);
console.log(dateText);
});
};
};
var options = {
dateFormat: "mm/dd/yy",
onSelect: function (dateText) {
updateModel(dateText);
},
showButtonPanel: true
};
elem.datepicker(options);
}
};
});這裏我使用的指令進行angularjs formly
[{
"id": "fromdate",
"key": "fromdate",
"type": "input",
"ngModelAttrs": {
"datePicker": {
"attribute": "date-picker"
}
},
"templateOptions": {
"required": true,
"datePicker": "",
"label": "From Date :"
}
}, {
"id": "todate",
"key": "todate",
"type": "input",
"ngModelAttrs": {
"datePicker": {
"attribute": "date-picker"
}
},
"templateOptions": {
"required": true,
"datePicker": "",
"label": "To Date :"
}
}]
要日期應該更高? –
@ gayathri耶日期應該大於從日期 –