@@ -15,7 +15,7 @@ export class MonthPickerComponent implements OnInit {
1515 selectedMonthMoment : moment . Moment ;
1616 selectedMonthIndex : number ;
1717 selectedYearMoment : moment . Moment ;
18- selectedMonthYear : number ;
18+ selectedYear : number ;
1919
2020 selectedYearText : string ;
2121 months : Array < string > = [ ] ;
@@ -26,12 +26,12 @@ export class MonthPickerComponent implements OnInit {
2626 this . selectedMonthMoment = moment ( ) ;
2727 this . months = moment . months ( ) ;
2828 this . selectedMonthIndex = this . selectedMonthMoment . month ( ) ;
29- this . selectedMonthYear = this . selectedYearMoment . year ( ) ;
29+ this . selectedYear = this . selectedYearMoment . year ( ) ;
3030 this . updateYearText ( ) ;
3131 }
3232
3333 ngOnInit ( ) {
34- this . selectDate ( this . selectedMonthIndex , this . selectedMonthYear ) ;
34+ this . selectDate ( this . selectedMonthIndex , this . selectedYear ) ;
3535 }
3636
3737 updateYearText ( ) {
@@ -48,23 +48,21 @@ export class MonthPickerComponent implements OnInit {
4848 this . updateYearText ( ) ;
4949 }
5050
51- selectMonth ( index : number ) {
52- this . selectedMonthMoment = moment ( ) . month ( index ) ;
53- this . selectedMonthIndex = this . selectedMonthMoment . month ( ) ;
54- this . selectedMonthYear = this . selectedYearMoment . year ( ) ;
55- this . selectDate ( this . selectedMonthIndex , this . selectedMonthYear ) ;
51+ selectMonth ( monthIndex : number ) {
52+ this . selectedMonthIndex = monthIndex ;
53+ this . selectedYear = this . selectedYearMoment . year ( ) ;
54+ this . selectDate ( this . selectedMonthIndex , this . selectedYear ) ;
5655 }
5756
5857 isSelectedMonth ( monthIndex : number ) {
5958 return (
6059 this . selectedMonthIndex === monthIndex &&
61- this . selectedMonthYear === this . selectedYearMoment . year ( )
60+ this . selectedYear === this . selectedYearMoment . year ( )
6261 ) ;
6362 }
6463
6564 selectDate ( monthIndex : number , year : number ) {
66- this . dateSelected . emit ( { monthIndex : monthIndex , year : year } ) ;
65+ this . dateSelected . emit ( { monthIndex, year } ) ;
6766 }
68-
6967}
7068
0 commit comments