How I can make a restriction for date selection in date picker?


#1

How I can make a restriction for date selection such as just show date 1 & 15 only for every month when select date in datepicker for ionic app? Please check out my script below:

template html

  <ion-view  title="Template">
    <ion-nav-buttons side="secondary">
        <button class="button-icon icon ion-calendar assertive" ng-click="datePicker()">  </button>
  </ion-nav-buttons>
<div class="bar bar-subheader bar-assertive">

</div>
      <ion-content class="has-header has-subheader ">  
     <p>{{currentDate}}</p>     
   </ion-content>
</ion-view>

  </body>
</html>

Controller js

.controller('MyCtrl', function($scope, $rootScope, $ionicPopup, $state, $filter) {

  $scope.datePicker =function() { 
  $ionicPopup.prompt({
    title: 'Date Picker',
    template: 'Please Input Date',
    inputType: 'date',
     }).then(function(res) {
         if (res) {
       $scope.currentDate = res;
       var newdate = $filter('date')($scope.currentDate,'yyyy/MM/dd'); 
     $rootScope.showLoading("Loading data..");

 } else {
   console.log('nothing');
      }

 });

        }

});

I hope anyone can help me to solve this problem


#2

An answer is no, input date is not flexible as much, reference: http://www.w3.org/TR/html-markup/input.date.html

What you can do is use 3rd party Ionic date plugin: http://www.gajotres.net/must-have-plugins-for-ionic-framework/
it’s under chapter 3: Ionic Date Picker.

Implement it into your project and use CSS to disable all not needed dates. It will take some time but I think you can manage to do that.


#3

Thanks for your answer but could you give an example code to disable all not needed dates and just show date 1 & 15?