Html/css J query Javascript

jQuery UI Datepicker with AngularJS

JQuery UDatePickerI Datepicker with AngularJS

How to use jquery ui calendar with angular js?
Recently I found out it is not straight forward to use jQuery UI together with Angular.js. Reason: if you are using the usual initialization like


In our factory function we get three parameters. Important are the scope, which is the current scope of the enclosing controller, and the element, which is the annotated HTML element. As “element” is a jQuery object, we can easily call the datepicker method which initializes the jQuery UI datepicker.

The interesting part happens in the onSelect method. It is a datepicker callback which is executed when the user selects a date. The argument is entering the method as text. Our goal is to apply the changed value to the controller scope.


<div id="wrapper" ng-app="myApp">

<p>{{model.StartDate || "00/00/0000"}}</p>
  <input type="text" name="Startdate" calendar ng-model="model.StartDate" class="form-control" />


This is the directive which wraps the datepicker.

var myapp = angular.module('myapp');
myapp.directive('calendar', function () {
    return {
        require: 'ngModel',
        link: function (scope, el, attr, ngModel) {
                dateFormat: 'dd-mm-yy',
                changeMonth: true,
                changeYear: true,
                onSelect: function (dateText) {
                    scope.$apply(function () {


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


2 thoughts on “jQuery UI Datepicker with AngularJS”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.