我的弹出窗口中有一个数据贴纸,在打开弹出窗口时第一次正常工作。一旦我们关闭弹出窗口并重新打开,则datepicker不起作用。 我为与datepicker相关联的ng-model放置了一个观察器,发现值即将到来,但是datepicker文本框为空,并且值未分配给此文本框。请查看下面的代码并指导我正在做的错误。提前感谢您花时间查看此问题。
分享我正在使用的基本代码:
打开弹出的代码:
var templateAbs = null,
templateAbsInit = angular.noop;
templateAbs = "Templates/_AbstractorServices";
templateAbsInit = function (modal) {
modal.element.find("#recordingDateDoc").datepicker();
modal.element.find("#recordingDateOwner").datepicker();
};
/* Open modal to Abstractor Services Modal. */
modalService.showModal({
templateUrl: "Templates/_AbstractorServices",
controller: "AbstractorServicesCtrl",
scope: $scope
}).then(function (modal) {
modal.element.modal();
templateAbsInit(modal);
modal.close.then(function (result) {
// nothing else here for now
});
});`
cshtml页面中的Datepicker:
<div class="col-md-2 rowdatepicker">
<label>
RECORDING DATE
</label>
<input type="text" class="abs-textboxdpsmall" name="textbox-recordingDate" id="input is blank " ng-model="abstractorServicesParams.recordingDate"
required />
</div>
控制器中的观察者,我可以从日期选择器中看到所选值
$scope.$watch("abstractorServicesParams.recordingDate", function (newval) {
if (newval != undefined) {
if ($scope.showRecordingDateOwner == true && newval != null && newval.length == 0)
$scope.submitdisableRdate = true;
else if ($scope.showRecordingDateOwner == true && newval != null && newval.length > 0)
$scope.submitdisableRdate = false;
}
else
$scope.submitdisableRdate = true;
});
从cshtml页面弹出关闭
<button type="button" class="btn btn-default" data-dismiss="modal">CANCEL</button>