Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-ui-bootstrap - Date Picker - How can I restrict access to the date-selector in popup?

At the moment, I can first select the year, then the month, and then, the date. However, I only need access to month and the year. I'm not sure how to disable the date-selector option.

Also, I would like to get rid of all the footer buttons (today, clear, etc) in the date-picker as well. How can I achieve this ?

I'm looking for something similar to '$scope.showweeks = false;'

Below is my Plunker example

Plunker- Month year picker

Please feel free to direct me to any documentations available. So far, I could only find

http://angular-ui.github.io/bootstrap/

Thanks

like image 977
Ren Avatar asked Mar 11 '14 10:03

Ren


1 Answers

You can try to use datepicker for Bootstrap with jQuery wrapped by directive.

See Plunker

JS

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.var1 = '07-2013';
});


app.directive('datetimez', function() {
    return {
        restrict: 'A',
        require : 'ngModel',
        link: function(scope, element, attrs, ngModelCtrl) {
          element.datetimepicker({
           format: "MM-yyyy",
           viewMode: "months", 
            minViewMode: "months",
              pickTime: false,
          }).on('changeDate', function(e) {
            ngModelCtrl.$setViewValue(e.date);
            scope.$apply();
          });
        }
    };
});

HTML

   <div id="date" class="input-append" datetimez ng-model="var1">
      <input data-format="MM-yyyy" type="text" id="input1" name="input1"></input>
      <span class="add-on">
        <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
      </span>
    </div>

enter image description here

like image 161
Maxim Shoustin Avatar answered Nov 01 '22 16:11

Maxim Shoustin