A Pen by tutorialab.com on CodePen.
Created
August 7, 2018 06:05
-
-
Save SompalSingh/7a8bc875481f4603760ea6bef36788fa to your computer and use it in GitHub Desktop.
jQuery UI Datepicker with AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="wrapper" ng-app="myApp"> | |
<p>{{datePicker || "00/00/0000"}}</p> | |
<input type="text" ng-model="datePicker" datepicker /> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp', []); | |
myApp.directive("datepicker", function () { | |
return { | |
restrict: "A", | |
require: "ngModel", | |
link: function (scope, elem, attrs, ngModelCtrl) { | |
var updateModel = function (dateText) { | |
scope.$apply(function () { | |
ngModelCtrl.$setViewValue(dateText); | |
}); | |
}; | |
var options = { | |
dateFormat: "dd/mm/yy", | |
onSelect: function (dateText) { | |
updateModel(dateText); | |
} | |
}; | |
elem.datepicker(options); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #3568AD; | |
} | |
#wrapper { | |
font: 20px Calibri; | |
width: 100px; | |
margin: 0 auto; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UI Date picker