Implement correctly Angular ui-bootstrap date picker

0

I just integrated the datepicker into a project but it does not work correctly.

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>

Driver

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;
  };

The current date is displayed as soon as you load the view but nothing happens when you do click in the input or in the button.

    
asked by Gabo Ruiz 08.07.2017 в 00:45
source

1 answer

0

Add a date format with the datetime-picker property to the input

<div class="form-group">
<label>Date</label>
<p class="input-group">
    <input type="text" class="form-control"
       datetime-picker="dd/MM/yyyy"
       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>

    
answered by 13.07.2017 в 08:59