I'm trying to convert jQuery plugin into directive. Here is the library: Github.
In the documentation there is an option :
$(document).ready(function() {
$("#datepicker").datepicker();
$("#datepickerbtn").click(function(event) {
event.preventDefault();
$("#datepicker").focus();
})
});
Directive I've created :
app.directive('dateP', function(){
return{
restrict:'A',
require:'ngModel',
link:function(scope, element, attr, ngModel){
$(element).datepicker(scope.$eval(attr.dateP));
console.log('hey');
ngModel.$setViewValue(scope);
}
}
});
but it's not working , any help would be appreciate it .
Plunker .
I've read this : https://amitgharat.wordpress.com/2013/02/03/an-approach-to-use-jquery-plugins-with-angularjs/