angularjs - Angular JS directive with JQuery Datepicker -


i'm totally new angular js. somehow managed integrate jquery ui datepicker in angular js project. want format date picked jquery datepicker iso date format i'm not being able do. here code.

html

<input type="text" ng-model="event.when.start" datetime-picker> 

angular controller

myapp.directive('datetimepicker', function() {    return {         require : 'ngmodel',         link : function (scope, element, attrs, ngmodel) {             $(function(){                 element.datetimepicker({                     dateformat:'yy-mm-dd',                     mindate: 0,                     yearrange: '1920:2012',                     minute: 0,                     stepminute: 15,                     onselect:function (datetext, inst) {                         var dt = new date(datetext);                         alert(dt.toisostring());                         ngmodel.$setviewvalue(dt.toisostring());                         scope.$apply();                     }                 });             });         }     } }); 

screenshot

enter image description here

note*: i'm being able alert value though.

simply below

myapp.controller('myctrl',function myctrl ($scope){     $scope.event = {when : {start : ''}}     $scope.event.when.start = new date(); }).      myapp.directive('datetimepicker', function() {        return {             require : 'ngmodel',             link : function (scope, element, attrs, ngmodel) {                 $(function(){                     element.datetimepicker({                         mindate: 0,                         yearrange: '1920:2012',                         minute: 0,                         stepminute: 15,                         onselect:function (datetext, inst) {                              scope.$apply(function(){                                scope.event.when.start = new date(datetext);                             });                         }                     });                 });             }         }     }); 

don't use dateformat:'yy-mm-dd', if need iso date


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -