I'm using ngx bootstrap datepicker in the project
Needed only month and year to be selected like the above image
<input type="text"
class="form-control"
(bsValueChange)="modelChanged($event)"
#dp="bsDatepicker"
bsDatepicker [(bsValue)]="bsValue"
[bsConfig]="{ dateInputFormat: 'YYYY-MM-DD' }"
>
is there any way to config the date-picker like this? or Suggest any alternative date-picker which allow this functionality
you should import the following:
import { BsDatepickerConfig, BsDatepickerViewMode } from 'ngx-bootstrap/datepicker';
@Component({
selector: 'demo-datepicker-min-mode',
templateUrl: './min-mode.component.html'
})
export class DemoDatepickerMinModeComponent implements OnInit {
bsValue: Date = new Date(2017, 7);
minMode: BsDatepickerViewMode = 'month'; // change for month:year
bsConfig: Partial<BsDatepickerConfig>;
ngOnInit(): void {
this.bsConfig = Object.assign({}, {
minMode : this.minMode
});
}
}
and in your HTML file
<div class="row">
<div class="col-xs-12 col-12 col-md-4 form-group">
<input type="text"
class="form-control"
[bsConfig]="bsConfig"
#dp="bsDatepicker"
bsDatepicker [(bsValue)]="bsValue">
</div>
<div class="col-xs-12 col-12 col-md-3 form-group">
<button class="btn btn-success" (click)="dp.toggle()" type="button">Date Picker</button>
</div>
</div>
<br>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With