Skip to content

Commit

Permalink
FIX: Issue 156, min / max Date Year Generation (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
gigo1980 authored and jkuri committed Feb 15, 2017
1 parent a26a70b commit 13d3b4d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ng2-datepicker/ng2-datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ export class DatePickerComponent implements ControlValueAccessor, OnInit {
momentObj: null
});

this.generateYears();

this.outputEvents = new EventEmitter<{ type: string, data: string | DateModel }>();

if (!this.inputEvents) {
Expand Down Expand Up @@ -176,6 +174,7 @@ export class DatePickerComponent implements ControlValueAccessor, OnInit {
this.maxDate = null;
}

this.generateYears();
this.generateCalendar();
this.outputEvents.emit({ type: 'default', data: 'init' });

Expand Down Expand Up @@ -305,8 +304,8 @@ export class DatePickerComponent implements ControlValueAccessor, OnInit {
}

generateYears() {
let date: moment.Moment = this.options.minDate || Moment().year(Moment().year() - 40);
let toDate: moment.Moment = this.options.maxDate || Moment().year(Moment().year() + 40);
let date: moment.Moment = this.minDate || Moment().year(Moment().year() - 40);
let toDate: moment.Moment = this.maxDate || Moment().year(Moment().year() + 40);
let years = toDate.year() - date.year();

for (let i = 0; i < years; i++) {
Expand Down

0 comments on commit 13d3b4d

Please sign in to comment.