AngularJS model parsing without user input event -


i'm implementing dale lotts datetimepicker , datetimeinput modules in app;

//my input <input data-ng-model="order.startdate" data-date-time-input="dd/mm/yyyy hh:mm" data-date-formats="['dd/mm/yyyy hh:mm', 'd/m/yyyy', 'd/m/yyyy h:mm', 'd/m/yyyy h.mm']" type="text" class="field start-field font-l inline numeric" ng-focus="datetime.order.start = true" /> //my datetimepicker <datetimepicker id="datetime-order" data-on-set-time="datetime.order.start=false" data-ng-model="order.startdate" data-datetimepicker-config="{ minview: 'hour'}"></datetimepicker> 

the input , datetimepicker binded data-ng-model when pick date datetimepicker value formatted , displayed in input.

data-model-type="yyyy-mm-ddthh:mm:ss" in input added adapt model value in compatible format api, it's not working: when pick date datetimepicker input model not formatted using given params it's formatted in standard data format instead. model-type attribute works when there user event directly on input, followed blur event.

i tried add watcher on input value , force $parsers execution updating $viewvalue

//inside datetimeinput directive    scope.$watch(function(){  return element.val(); }, function(){  controller.$setviewvalue(controller.$viewvalue); }); 

but didn't work, , tried simulate user action on input updating element value , triggering blur event

scope.$watch(function(){      return element.val();     }, function(){      element.val(controller.$viewvalue);      element.triggerhandler('input');     }); 

but didn't work too.

how can manually force parsers format input model after pick date timepicker?

i resolved configuring datetimepicker model instead of parsing input model:

<datetimepicker ... data-datetimepicker-config="{ minview: 'hour', **modeltype: 'yyyy-mm-ddthh:mm:ss'**}"></datetimepicker> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -