@@ -15,7 +15,7 @@ export class MonthPickerComponent implements OnInit {
15
15
selectedMonthMoment : moment . Moment ;
16
16
selectedMonthIndex : number ;
17
17
selectedYearMoment : moment . Moment ;
18
- selectedMonthYear : number ;
18
+ selectedYear : number ;
19
19
20
20
selectedYearText : string ;
21
21
months : Array < string > = [ ] ;
@@ -26,12 +26,12 @@ export class MonthPickerComponent implements OnInit {
26
26
this . selectedMonthMoment = moment ( ) ;
27
27
this . months = moment . months ( ) ;
28
28
this . selectedMonthIndex = this . selectedMonthMoment . month ( ) ;
29
- this . selectedMonthYear = this . selectedYearMoment . year ( ) ;
29
+ this . selectedYear = this . selectedYearMoment . year ( ) ;
30
30
this . updateYearText ( ) ;
31
31
}
32
32
33
33
ngOnInit ( ) {
34
- this . selectDate ( this . selectedMonthIndex , this . selectedMonthYear ) ;
34
+ this . selectDate ( this . selectedMonthIndex , this . selectedYear ) ;
35
35
}
36
36
37
37
updateYearText ( ) {
@@ -48,23 +48,21 @@ export class MonthPickerComponent implements OnInit {
48
48
this . updateYearText ( ) ;
49
49
}
50
50
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 ) ;
56
55
}
57
56
58
57
isSelectedMonth ( monthIndex : number ) {
59
58
return (
60
59
this . selectedMonthIndex === monthIndex &&
61
- this . selectedMonthYear === this . selectedYearMoment . year ( )
60
+ this . selectedYear === this . selectedYearMoment . year ( )
62
61
) ;
63
62
}
64
63
65
64
selectDate ( monthIndex : number , year : number ) {
66
- this . dateSelected . emit ( { monthIndex : monthIndex , year : year } ) ;
65
+ this . dateSelected . emit ( { monthIndex, year } ) ;
67
66
}
68
-
69
67
}
70
68
0 commit comments