Skip to content

Instantly share code, notes, and snippets.

@mishudark
Last active December 17, 2015 06:18
Show Gist options
  • Save mishudark/5563880 to your computer and use it in GitHub Desktop.
Save mishudark/5563880 to your computer and use it in GitHub Desktop.
<input type="text" datepicker ng-model="myobj.myvalue" />
myApp.directive('myDatepicker', function ($parse) {
return function (scope, element, attrs, controller) {
var ngModel = $parse(attrs.ngModel);
$(function(){
element.datepicker({
...
onSelect:function (dateText, inst) {
scope.$apply(function(scope){
// Change binded variable
ngModel.assign(scope, dateText);
});
}
});
});
}
});
function MyCtrl($scope) {
$scope.userInfo = {
person: {
mDate: '1967-10-07'
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment