Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Year selection #15

Closed
lior-greenblatt opened this issue Jun 3, 2015 · 6 comments
Closed

Year selection #15

lior-greenblatt opened this issue Jun 3, 2015 · 6 comments

Comments

@lior-greenblatt
Copy link

Thanks for this :)
Just wanted to inquire if there are any plans of selecting a year?
e.g. to set birth date (think 20, 30, 40 years back)

@rajeshwarpatlolla
Copy link
Owner

For now, there is no such functionality. But i will try to implement in the future releases.

@lior-greenblatt
Copy link
Author

Thanks for the prompt reply.

I took the liberty of playing around with it and added a selection with the following changes.
in the template:

  <div class="col col-80 text-center">{{currentMonth}} - <select ng-model="currentYear" ng-options="y as y for y in years" ng-change="changedYear(currentYear)"></select></div>

in the directive:
added to scope:

        yearsLow: '@'
        yearsHigh: '@'

added to link:

var i;
i = scope.yearsLow;
while (i >= 0) {
  scope.years.push(scope.today.year - i);
  i--;
}
i = 1;
while (i <= scope.yearsHigh) {
  scope.years.push(scope.today.year + i);
  i++;
}
scope.changedYear = function(newYear) {
  currentDate.setYear(newYear);
  scope.currentYear = currentDate.getFullYear();
  return refreshDateList(currentDate);
};

And finally used:

<ionic-datepicker idate="date" disablepreviousdates="false" years-low="50" years-high="10">
            <button class="button button-block button-positive"> {{ date | date:'dd - MMMM - yyyy' }} </button>
</ionic-datepicker>

Hope it helps :)

@lior-greenblatt
Copy link
Author

One small thing I also noticed was the height of the calendar.
since some months show 6 weeks 180px wasn't enough (in case set was clicked before selecting a date) and the error message was under the last days of the month so I used 210px

@rajeshwarpatlolla
Copy link
Owner

Drop downs are added for selecting both month and year in the new version v0.3.0.

@lior-greenblatt
Copy link
Author

Great!!
Thank you

@arumuganainar
Copy link

Error: [$compile:nonassign] Expression 'undefined' in attribute 'idate' used with directive 'ionicDatepicker' is non-assignable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants