2017-07-07 66 views
0

我需要集成datepicker,但它不能正常工作。问题与角度UI引导Datepicker

这是我的HTML

<div class="form-group"> 
       <label>Date</label> 
       <p class="input-group"> 
     <input type="text" class="form-control" 
     datepicker-popup="mediumDate" 
     is-open="shipment.valuationDatePickerIsOpen" 
     ng-click="shipment.valuationDatePickerOpen()" 
     ng-model="shipment.valuationDate" /> 
    <span class="input-group-btn"> 
    <button type="button" class="btn btn-default" 
     ng-click="shipment.valuationDatePickerOpen($event)"> 
     <i class="fa fa-calendar"></i> 
    </button> 
</span> 
</p> 

</div> 

这是我的控制器

var vm = this; 
    // $scope.Eship; 

     vm.valuationDate = new Date(); 
    vm.valuationDatePickerIsOpen = false; 
    vm.opens = []; 

    $scope.$watch(function() { 
     return vm.valuationDatePickerIsOpen; 
    },function(value){ 
     vm.opens.push("valuationDatePickerIsOpen: " + value + " at: " + new Date()); 
    }); 

    vm.valuationDatePickerOpen = function ($event) { 

     if ($event) { 
      $event.preventDefault(); 
      $event.stopPropagation(); 
     } 
     this.valuationDatePickerIsOpen = true; 
    }; 

我已经导入UI的引导指令。 我不知道最新失踪或最新错误。

回答

0

您可以按照文档中给出了最简单的例子&再经过定制或操作该日期输入字段的模型值,

<p class="input-group"> 
    <input type="text" class="form-control" uib-datepicker-popup ng-model="dt" is-open="popup1.opened" 
    datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" /> 
    <span class="input-group-btn"> 
    <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button> 
    </span> 
</p> 

这里的链接,普拉克https://plnkr.co/edit/PbuiCq5f3NVaWx6OAW8D?p=preview

0

你有问题因为您使用的是datepicker-popup而不是uib-datepicker-popup指令。 只要确保您使用的是正确版本的Angular和UI Bootstrap,然后查看该模块的文档。

我定你的榜样,请在这里找到代码:https://plnkr.co/edit/cMj8IXD7KYTUgi7hY0W7?p=preview

我希望它能帮助。

+0

我这样做,它的作品。但它不会在数据库中更新。我即将做错了什么? –

+0

我认为你的问题是与日期选择器集成。也许您需要为您的数据库/服务集成发布另一个问题。 – luixaviles