Skip to content

Commit

Permalink
fix(module:calendar): fix calendar year picker (#2355)
Browse files Browse the repository at this point in the history
close #2351
  • Loading branch information
vthinkxie committed Oct 25, 2018
1 parent 65fc10a commit a4a948c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/calendar/nz-calendar-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ export class NzCalendarHeaderComponent implements OnInit {
@Output() modeChange: EventEmitter<'month' | 'year'> = new EventEmitter();

@Input() fullscreen: boolean = true;
@Input() activeDate: Date = new Date();

@Input()
set activeDate(value: Date) {
this._activeDate = value;
this.setUpYears();
}

get activeDate(): Date {
return this._activeDate;
}

@Output() yearChange: EventEmitter<number> = new EventEmitter();
@Output() monthChange: EventEmitter<number> = new EventEmitter();

_activeDate = new Date();
yearOffset: number = 10;
yearTotal: number = 20;
years: Array<{ label: string, value: number }>;
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/nz-calendar-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ describe('Calendar Header', () => {

expect(yearModel.model).toBe(2001);
expect(monthModel.model).toBe(1);
const headerComponent = header.injector.get(NzCalendarHeaderComponent);
expect(headerComponent.years[0].value).toBe(1991);
});
});

Expand Down

0 comments on commit a4a948c

Please sign in to comment.