Angularjs Datepicker Example using directive

April 5, 2018 | Category : Angular

datepicker is a primary requirement for every website. if you want to add datepicker in your angular js application then you are a right place. here i will give you full example of how to implement datepicker using angularjs directive.

In this example i simply use jquery ui library for datepicker and then i will use datepicker function using angularjs directive. So let's see bellow full example and understand how it works. It is very simple and easy example.


<!DOCTYPE html>



<title>Welcome to</title>

<link href="" rel="stylesheet" type="text/css" /> <script src=""></script>

<script src=""></script>

<script src=""></script>



<div ng-app="date">

<div ng-controller="HDTutoCtrl">

<!-- jq -->

jq date:<input type="text" id="date" name="date" ng-model="date">


<!-- ng -->

ng date:<input type="text" datepicker ng-model="date2" />




<script type="text/javascript">

$(function () {


dateFormat: 'yy-mm-dd'



angular.module("date", [])

.directive("datepicker", function () {

return {

restrict: "A",

link: function (scope, el, attr) {


dateFormat: 'yy-mm-dd'





.controller("HDTutoCtrl", function ($scope) {





You can see demo from here : Demo

I hope you found your best solution....