如何在Angular UI Modal中使用Datepicker

时间:2018-11-30 16:23:24

标签: angularjs angularjs-directive angular-ui-modal

当在页面中使用时,我有字符串datepicker可以正常工作,但是当我在Angular UI模态'$uibModal'中使用此datepicker时,它不能正常工作...如何使用它,我在此问题上花费了4个小时,但没有不工作 https://cdnjs.com/libraries/bootstrap-datetimepicker

  <div class="col-md-4">
            <div class="input-group date form_date " data-date="" data-date-format="dd-mm-yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
                <input ng-model="FromDate" autocomplete="off" id="FromDate" class="form-control input-height" placeholder="Date" type="text">
                <span class="input-group-addon"><span class="fa fa-calendar"></span></span>
            </div>
        </div>



 var modalInstance = $uibModal.open({
            animation: this.animationsEnabled,
            templateUrl: '../../../Templates/AddModel.html',
            controller: 'RCtrl',
            scope: $scope,
            size: 'lg'
        });
        $scope.modalInstance = this.modalInstance;
        return modalInstance.result;

1 个答案:

答案 0 :(得分:0)

这是您修改的代码:

var modalInstance = $uibModal.open({
      animation: this.animationsEnabled,
      templateUrl: '../../../Templates/AddModel.html',
      controller: 'RCtrl',
      scope: $scope,
      size: 'lg'
});

modalInstance.opened.then(function(){
   $timeout(function(){
     $('#FromDate').datetimepicker();
   }, 500) 
});

$scope.modalInstance = modalInstance;

return modalInstance.result;