I am trying to intialize the date picker to the textbox using angular JS directive.
Here is my angular JS directive
var testapp = angular.module('testApp',[]);
testapp.directive('mydatepicker', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModelCtrl) {
$(element).datepicker({
dateFormat: 'DD, d MM, yy',
onSelect: function (date) {
scope.date = date;
scope.$apply();
}
});
}
};
});
HTML code I wrote :
<body ng-app="testApp" ng-controller="myController">
// some other html code
<input type="text" ng-model="date" mydatepicker />
<br/>
{{ date }}
//some other html code
</body>
Datepicker is not getting intialized. Here is the JS Fiddle
http://jsfiddle.net/5ua9guee/19/
In the JS Fiddle I am getting two errors :
Uncaught ReferenceError: jQuery is not defined
Uncaught Error: [$injector:modulerr] Failed to instantiate module App due to:
I tried the existing posts but no one worked for me.
Thank You