Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • AngularJS Tutorial
  • AngularJS Directives
  • AngularJS Functions
  • AngularJS Filters
  • AngularJS Examples
  • AngularJS Interview Questions
  • Angular ngx Bootstrap
  • AngularJS Cheat Sheet
  • AngularJS PrimeNG
  • JavaScript
  • Web Technology
Open In App
Next Article:
How to make Datepicker using Angular UI Bootstrap ?
Next article icon

What is the use of Bootstrap Datepicker in Angular?

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will see the use of Bootstrap Datepicker in Angular. The Datepicker is used to make a component that will be shown by using a calendar and we can select the date from it. Adding Bootstrap to the Angular Project can make the better UI design, along with providing some in-built classes for Date that help us to implement it directly.

Bootstrap Datepicker in Angular can be used in the following ways:

  • Adding Bootstrap through Angular CLI & NPM, & then creating & using the Datepicker Component
  • By installing the Angular ngx Bootstrap & then using the Datepicker Component (Angular ng Bootstrap Datepicker Component)

Steps for Installing & Configuring the Angular Application

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install dependency

ng add @ng-bootstrap/ng-bootstrap  npm install --save angular-bootstrap-datetimepicker bootstrap moment open-iconic

Step 4: Add CSS to ./src/styles.css

@import '~bootstrap/dist/css/bootstrap.min.css';  @import '~open-iconic/font/css/open-iconic-bootstrap.css';

Project Structure

It will look like the following:

z123

Example 1: In this example, we will create a simple Bootstrap Datepicker in Angular. We will be adding Bootstrap through Angular CLI & NPM, & then creating & using the Datepicker Component.

HTML
<!-- app.component.html --> <h2 style="color: green;">GeeksforGeeks</h2> <h2>   What is the use of Bootstrap    Datepicker in Angular? </h2> <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>             </div>         </div>     </div> </form> 
JavaScript
// app.component.ts import { Component } from '@angular/core'; import { BrowserModule, DomSanitizer } from     '@angular/platform-browser'  @Component({     selector: 'app-root',     templateUrl: './app.component.html',     styleUrls: ['./app.component.css'] }) export class AppComponent {     model: any } 
JavaScript
//app.module.ts import { NgModule }      from '@angular/core'; import { FormsModule, ReactiveFormsModule }     from '@angular/forms'; import { BrowserModule }     from '@angular/platform-browser'; import { BrowserAnimationsModule }     from '@angular/platform-browser/animations'; import { AppComponent }      from './app.component'; import { NgbModule }      from '@ng-bootstrap/ng-bootstrap'; import { DlDateTimeDateModule, DlDateTimePickerModule }     from 'angular-bootstrap-datetimepicker';  @NgModule({     bootstrap: [         AppComponent     ],     declarations: [         AppComponent     ],     imports: [         FormsModule,         BrowserModule,         BrowserAnimationsModule,         ReactiveFormsModule,         DlDateTimeDateModule,         DlDateTimePickerModule,     ] }) export class AppModule { } 

Output:

Recording-2023-12-01-at-141235

Example 2: In this example, we will use Bootstrap Datepicker in Angular by ngx Bootstrap & then use the Datepicker Component (Angular ng Bootstrap Datepicker Component). We will also display the selected date in the text.

HTML
<!-- app.component.html --> <h2 style="color: green;">GeeksforGeeks</h2> <h2>   What is the use of Bootstrap    Datepicker in Angular? </h2> <ngb-datepicker #dp [(ngModel)]="model"                  (navigate)="date = $event.next"> </ngb-datepicker> <hr /> <pre>Selected Date: {{ model | json }}</pre> 
JavaScript
//app.component.ts import { Component, inject }      from '@angular/core'; import { NgbCalendar, NgbDatepickerModule, NgbDateStruct }     from '@ng-bootstrap/ng-bootstrap'; import { FormsModule } from '@angular/forms'; import { JsonPipe } from '@angular/common'; @Component({     selector: 'app-root',     templateUrl: './app.component.html',     styleUrls: ['./app.component.css'],     imports: [NgbDatepickerModule, FormsModule, JsonPipe],     standalone: true, }) export class AppComponent {      model: NgbDateStruct;     date: { year: number; month: number }; } 
JavaScript
//app.module.ts import { NgModule }      from '@angular/core'; import { FormsModule, ReactiveFormsModule }     from '@angular/forms'; import { BrowserModule }     from '@angular/platform-browser'; import { BrowserAnimationsModule }     from '@angular/platform-browser/animations'; import { AppComponent }      from './app.component'; import { NgbModule }      from '@ng-bootstrap/ng-bootstrap';  @NgModule({     bootstrap: [         AppComponent     ],     declarations: [         AppComponent     ],     imports: [         FormsModule,         BrowserModule,         BrowserAnimationsModule,         ReactiveFormsModule,         NgbModule     ] }) export class AppModule { } 

Output:

Recording-2023-12-01-at-143904


Next Article
How to make Datepicker using Angular UI Bootstrap ?
author
21mcsrltd
Improve
Article Tags :
  • Web Technologies
  • Bootstrap
  • AngularJS
  • Geeks Premier League
  • AngularJS-Questions
  • Geeks Premier League 2023

Similar Reads

  • How to make Datepicker using Angular UI Bootstrap ?
    In this article, we will see how to make Datepicker using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers for providing better UI which can be used easily. Syntax: <div uib-datepicker></div> Download AngularUI from the link: https://
    1 min read
  • How to make Timepicker using Angular UI Bootstrap ?
    In this article, we will see how to make Dropdown using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers to provide better UI which can be used easily. Syntax: <div uib-timepicker></div> Download AngularUI from the link: https://angul
    1 min read
  • How To Use Bootstrap Icons In Angular?
    The most popular framework for making responsive and mobile-friendly websites is called Bootstrap. They include forms, typography, buttons, tables, navigation, modals, and picture carousels etc. These are built using CSS and HTML. It also supports plugins written in JavaScript. It provides the proce
    3 min read
  • Angular ng Bootstrap Datepicker Component
    Angular ng bootstrap is a bootstrap framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. In this article, we will see how to use Datepicker in angular ng bootstrap. The Datepicker is used to make a compone
    2 min read
  • How to setting up Datepicker in Bootstrap ?
    A Datepicker is an input tool that allows users to select dates from a calendar view rather than typing manually. To set it up in Bootstrap, integrate the Bootstrap Datepicker library using HTML, CSS, jQuery, and Bootstrap, customizing it with various options for functionality. Syntax$("#datepickerI
    3 min read
  • How to use bootstrap 4 in angular 2?
    Bootstrap is an open-source toolkit for developing with HTML, CSS, and JS. The Bootstrap framework can be used together with modern JavaScript web & mobile frameworks like Angular. Bootstrap 4 is the newest version of Bootstrap, which is the most popular HTML, CSS, and JavaScript framework. This
    2 min read
  • How to Install Bootstrap in Angular?
    If you have completed your practice in the field of HTML & CSS and want to develop more interesting and attractive webpages in the future, moving ahead for the Bootstrap topic along with the Angular concept will be appropriate for you. However, to have Bootstrap on your Angular Project you shoul
    5 min read
  • Angular MDBootstrap Position Utilities
    MDBootstrap is a Material Design and bootstrap-based Angular UI library that is used to make attractive webpages with its seamless and easy-to-use component. In this article, we will know how to use Position Utilities in Angular MDBootstrap. The Position Utilities allows a user to change the positio
    2 min read
  • How to make Popover using Angular UI Bootstrap ?
    In this article, we will see how to make Dropdown using Angular UI bootstrap Angular UI Bootstrap is an Angular JS framework created by Angular UI developers for providing better UI which can be used easily. Syntax: <div uib-popover></div> Download AngularUI from the link: https://angula
    1 min read
  • How to Sort List by Date Filter in AngularJS ?
    AngularJS is a feature-based JavaScript framework that uses various tools to create dynamic single-page web applications. While developing the application we have the requirement to play with the data in AngularJS and sort this list of data by a date properly in descending order. This can be done us
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences