jquery - Bootstrap DateTimePicker - on change event for Angular -


given demo below:

http://jsfiddle.net/adukg/8851/

i want every time date changes controller value update. every time new date selected box below value ng-model changes.

enter image description here

however upon using following directive error written above.

app.directive('datetimepicker', function () {     return {         restrict: 'a',         require : 'ngmodel',         link : function (scope, element, attrs, ngmodelctrl) {              element.datetimepicker({                  onrender:function (date) {                      // triggers digest update model                     scope.$apply(function () {                         ngmodelctrl.$setviewvalue(date);                     });                  }              });         }     }  }); 

how can detect changes in angular datetimepicker?

bootstrap's datetimepicker plugin doesn't support change event in options of constructor, can use dp.change event of element added datetimepicker to:

  element.datetimepicker({});   element.on('dp.change', function(event) {      scope.$apply(function () {       ngmodelctrl.$setviewvalue(event.date.format());     });   }) 

here update jsfiddle:
http://jsfiddle.net/dekelb/fc9kuy3x/3/


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -