2014-11-17 84 views
2

我使用jQuery日期選擇器這樣的:日期選擇器不工作後的數據,駁回AngularJs

<div class="col-md-2 rowdatepicker"> 
    <label> 
     RECORDING DATE 
    </label> 
    <input type="text" class="abs-textboxdpsmall" name="textbox-recordingDate" id="recordingDateDoc" ng-model="abstractorServicesParams.recordingDate" ng-pattern="/^(\d{2})\/(\d{2})\/(\d{4})$/" required /> 
</div> 

-

function DatepickerInit() { 
    /* For calender control */ 
    $('#modal-footer').modal('show'); 
    $("#recordingDateDoc").datepicker({ 
     showOn: "both", 
     changeYear: true, 
     changeMonth: true, 
     dateFormat: 'mm/dd/yy', 
     yearRange: '1700:2056' 
    }); 
} 

此日期選擇器處於AngularJs模式,它isworking罰款。模式中有一個關閉彈出窗口的按鈕。

<button type="button" class="btn btn-default" data-dismiss="modal" >CANCEL</button> 

爲了打開彈出,我使用下面的代碼時,彈出打開時DatepickerInit功能火災和每一件事工作正常高達here.After點擊

$scope.abstractorServices = function() { 
     ModalService.showModal({ 
      templateUrl: "Templates/_AbstractorServices", 
      controller: "AbstractorServicesCtrl", 
      scope: $scope 
     }).then(function (modal) { 
      modal.element.modal(); 
      modal.close.then(function (result) { 
       // nothing else here for now 
      }); 
     }); 
    }; 

第一次取消按鈕,彈出窗口關閉。再次打開相同的模式,日期選擇器不起作用,即使DatepickerInit函數此時也觸發,當模式加載時。

我無法跟蹤這個問題,請幫我確定一下Data-Dismiss從按鈕控制啓動後爲什麼DataPicker模式內部沒有工作的問題?

+4

您應該使用angular-ui datepicker,而不是基於jQuery的一個,但已準備好用於角度工作流(並且不使用jQuery,除非它存在)。通常應該使用指令來設置日期選擇器。 https://angular-ui.github.io/bootstrap/#/datepicker – GillesC

+2

你可以請創建jsFiddle/urunker的ur代碼? –

+0

你需要更好地描述問題,模塊使用什麼模塊,DatepickerInit()放置在哪裏,控制器內部或外部,執行時等。沒有這些簡單的信息很難提供幫助 – T4deu

回答

2

爲了打開彈出窗口這可能工作:

var modalInstance = $modal.open({ 
    templateUrl: 'Templates/_AbstractorServices', 
    controller: AbstractorServicesCtrl 
}); 

modalInstance.result.then(function (selected) { 
    $scope.selected = selected; 
}, function() { 
    //$log.info('Modal dismissed at: ' + new Date()); 
}); 

檢查這個plunker