2017-08-16 74 views
1

我想配置角度ui日期選擇器只選擇年和月,而不是顯示日子,但我不能這樣做。是我可以做的任何解決方案來實現這一點。 這就是我的plnkrAngularJS日期選擇器只有幾年和幾個月

http://plnkr.co/edit/JR2EuU?p=preview

angular.module('plunker', ['ui.bootstrap']); 
var DatepickerDemoCtrl = function ($scope) { 
    $scope.today = function() { 
    $scope.dt = new Date(); 
    }; 
    $scope.today(); 

    $scope.showWeeks = false; 


    $scope.open = function($event) { 
    $event.preventDefault(); 
    $event.stopPropagation(); 

    $scope.opened = true; 
    }; 

    $scope.dateOptions = { 
    'year-format': "'yy'", 
    'starting-day': 1, 
    'datepicker-mode':"'month'", 
    'min-mode':"month" 
    }; 

}; 

和多數民衆贊成我的觀點

<input type="text" class="form-control" datepicker-popup="MM/yyyy" ng-model="dt" is-open="opened" datepicker-options="{minMode: 'month'}" datepicker-mode="'month'" show-button-bar="false" show-weeks="false" close-on-date-selection="true" /> 
      <span class="input-group-btn"> 
    <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button> 

我在這裏發現了這個解決辦法,但我不想使用jQuery我期待使用的角度JS。 http://plnkr.co/edit/JUSAaQoFtU8Kw1KyvXwN?p=preview

+1

首先ui-bootstrap的版本很老,試試更新並檢查它的主頁,我也會推薦這個http://indrimuska.github.io/angular-moment-picker/這個句柄更原生這些年。 –

回答

0

在你的闖入者中,當我將角UI從0.10升級到0.12時,它工作正常。在您的index.html替換線5

<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>

我找不到在0.10版本的文檔。最遠的文檔是0.12

0

我使用indrimuska.github.io/angular-moment-picker,它確實運行良好,現代化和易於配置。

相關問題