app.component.ts
import { Component } from '@angular/core';
import { NgbCalendar } from '@ng-bootstrap/ng-bootstrap';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
model: NgbDateStruct = this.calendar.getToday();
constructor(private calendar: NgbCalendar) {}
}
app.component.html
<h4 style="padding-top:25px; padding-bottom:25px;">
Angular Bootstrap - How to use Datepicker
</h4>
<h5><b>Selected Date:</b></h5>
<h5>{{ model | json }}</h5>
<br/>
<ngb-datepicker
#datePicker
[(ngModel)]="model">
</ngb-datepicker>
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
// for angular bootstrap
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
// for angular bootstrap date picker
import {FormsModule} from '@angular/forms';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
NgbModule, // for angular bootstrap
FormsModule // for angular bootstrap date picker
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
- angular bootstrap - Select today from Datepicker
- angular bootstrap - Datepicker navigate to current month
- angular bootstrap - Datepicker navigate to specific year month
- angular bootstrap - Datepicker navigate select specific date
- angular bootstrap - Datepicker default selected date
- angular bootstrap - Datepicker default visible year month
- angular bootstrap - How to show Datepicker in a popup
- angular bootstrap - Select date range from Datepicker popup
- angular bootstrap - How to enable disable Datepicker
- angular bootstrap - Datepicker custom day style
- angular bootstrap - How to use Accordion
- angular bootstrap - Open an Accordion panel at a time
- angular bootstrap - Toggle Accordion panel on button click
- angular bootstrap - Disable collapse close Accordion panel
- angular bootstrap - How to use Nav