From 1384fd497fb788fdd0fafb7328639e11bde90bbf Mon Sep 17 00:00:00 2001 From: undermoodzyx Date: Sat, 22 Jul 2017 10:09:48 +0800 Subject: [PATCH] Fix issue #3337 Signed-off-by: undermoodzyx --- src/app/components/calendar/calendar.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/components/calendar/calendar.ts b/src/app/components/calendar/calendar.ts index 45d6a923821..45a3cacf2b2 100644 --- a/src/app/components/calendar/calendar.ts +++ b/src/app/components/calendar/calendar.ts @@ -458,7 +458,14 @@ export class Calendar implements AfterViewInit,AfterViewChecked,OnInit,OnDestroy if(this.currentMonth === 0) { this.currentMonth = 11; - this.currentYear--; + + if (this.yearOptions && this.yearOptions.length >= 1) { + if (--this.currentYear < this.yearOptions[0]) { + this.currentYear = this.yearOptions[0]; + } + } else { + this.currentYear--; + } } else { this.currentMonth--; @@ -476,7 +483,15 @@ export class Calendar implements AfterViewInit,AfterViewChecked,OnInit,OnDestroy if(this.currentMonth === 11) { this.currentMonth = 0; - this.currentYear++; + + if (this.yearOptions && this.yearOptions.length >= 1) { + const maxYear =this.yearOptions[this.yearOptions.length - 1]; + if (++this.currentYear > maxYear) { + this.currentYear = maxYear; + } + } else { + this.currentYear++; + } } else { this.currentMonth++;