Angular 13 Bootstrap Datepicker Example

By Hardik Savani October 20, 2023 Category : Angular

Hello all! In this article, we will talk about angular 13 bootstrap datepicker. Here you will learn how to use bootstrap datepicker in angular 13. it's simple example of angular 13 ng-bootstrap-datepicker. if you want to see example of bootstrap datepicker in angular 13 then you are a right place. Alright, let’s dive into the steps.

Ng Bootstrap is developed from bootstrap and they provide all bootstrap 3, bootstrap 4 and bootstrap 5 native Angular 13 directives like model, pagination, datepicker, buttons etc. Ng Bootstrap will help to easily use bootstrap ui.

In this example we will simply create one input field with datepicker, so you can use in your angular 13 application. we will use model step by step, so you can easily understand.


Step 1: Create New App

You can easily create your angular app using bellow command:

ng new my-new-app

Step 2: Install Bootstrap 5

In this step, we will install bootstrap core package. so we can use bootstrap css so let's install by following command:

npm install bootstrap --save

Now, we need to include bootstrap css like "node_modules/bootstrap/dist/css/bootstrap.min.css", so let's add it on angular.json file.



"styles": [





Step 3: Install Ng Bootstrap

In this step, we will install Ng Bootstrap package. so we can use bootstrap ui so let's install by following command:

npm install --save @ng-bootstrap/ng-bootstrap

Step 4: Import Module

In this step, we need to import NgbModule and FormsModule to app.module.ts file. so let's import it as like bellow:


import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

import { FormsModule } from '@angular/forms';


declarations: [



imports: [





providers: [],

bootstrap: [AppComponent]


export class AppModule { }

Step 5: Updated View File

Now here, we will updated our html file. we will create simple bootstrap input fields for datepicker.

so let's put bellow code:


<h1>Angular 13 Bootstrap 5 Datepicker Example -</h1>

<form class="form-inline">

<div class="form-group">

<div class="input-group">

<input class="form-control" placeholder="yyyy-mm-dd"

name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">

<div class="input-group-append">

<button class="btn btn-outline-secondary calendar" (click)="d.toggle()" type="button"></button>






<pre>Model: {{ model | json }}</pre>

Step 4: Use Component ts File

Now we need to update our component.ts file here we will write code of bootstrap datepicker model, let's update as like bellow:


import { Component } from '@angular/core';


selector: 'app-root',

templateUrl: './app.component.html',

styleUrls: ['./app.component.css']


export class AppComponent {

title = 'appBootstrap';


constructor() {}


Run Angular App:

All the required steps have been done, now you have to type the given below command and hit enter to run the Angular app:

ng serve

Now, Go to your web browser, type the given URL and view the app output:


I hope it can help you...