Closed acharyaks90 closed 4 years ago
Here is stackblitz code attached
https://stackblitz.com/edit/angular-ngmydatepicker
` myDpOptions: IAngularMyDpOptions = { dateRange: false, dateFormat: 'dd.mm.yyyy', inline:true // other options are here... };
myDateInit: boolean = true; model: IMyDateModel = null;
defaultMonth: IMyDefaultMonth ;
constructor(private cd : ChangeDetectorRef){
}
ngOnInit() {
this.model = {isRange: false, singleDate: {date: {
year: 2020,
month: 4,
day: 14
}}};
this.defaultMonth = {
defMonth:'01/2020'
}
}
trigLast(tenure){ console.log(tenure) if(tenure=='rest'){ this.defaultMonth = { defMonth:'03/2020'} this.model = {isRange: false, singleDate: {date: { year: 2020, month: 4, day: 14 }}}; this.model = JSON.parse(JSON.stringify( this.model )); this.model.singleDate ={date: { year: 2020, month: 4, day: 14 }} }else if(tenure=='three'){ this.defaultMonth = { defMonth:'01/2020'} this.model = {isRange: false, singleDate: {date: { year: 2020, month: 1, day: 14 }}}; this.model = JSON.parse(JSON.stringify( this.model )); this.model.singleDate ={date: { year: 2020, month: 1, day: 14 }} }else if(tenure=='six'){ this.defaultMonth = { defMonth:'09/2019'} this.model = {isRange: false, singleDate: {date: { year: 2019, month: 9, day: 14 }}}; this.model = JSON.parse(JSON.stringify( this.model )); this.model.singleDate ={date: { year: 2019, month: 9, day: 14 }} } this.myDpOptions = JSON.parse(JSON.stringify(this.myDpOptions )) }
changeDefaultMonthDynamically(): void {
this.defaultMonth = {
defMonth: '09/2020'
};
}
`
Html `
Hello @acharyaks90
You can set default view in options as follows:
import {IAngularMyDpOptions, DefaultView} from "angular-mydatepicker";
myDatePickerOptions: IAngularMyDpOptions = {
defaultView: DefaultView.Date,
or
defaultView: DefaultView.Month,
or
defaultView: DefaultView.Year,
}
I fixed this issue. Try version 0.5.2.
If you set the defaultMonth and set a date to the model at the same time the model value overrides the defaultMonth value. In this case the visible month is same what are the month and the year in the value of model.
The defaultMonth works ok without selected date.
@kekeh Thank very much quick support.
In Inline mode not able set date month year or default view to back to some date dynamically for single date mode I had tried using default month it work for very first time but then it doesn't work.
It works for non inline mode. in default view not able to understand what type of value is to be given i tried with date and other please give example of that also.