Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs timepicker ng-change

I am using AngularJS TimePicker (ui.bootstrap.timepicker). I would like to fire an event when the timepicker is changed. I looked for an ng-change attribute, but did not find one.

My purpose is that I would like to save the changes that are made to the model when the time is changed. Right now I've used ng-model to set the model, but I cannot figure out how to notify the controller so it can perform the save (the model is serialized to localstorage). I would like to avoid the use of a "Save" button if possible.

On a related note, I would also like to do the same thing for ui.bootstrap.datepicker.

like image 447
Josh Petitt Avatar asked Jul 21 '13 14:07

Josh Petitt


1 Answers

You could use $scope.$watch to listen for changes to the timepicker (or datepicker) and call whatever is needed in the Controller. Here is a plunker that is based on the bootstrap example but alerts whenever the time is changed. You should be able to apply a similar logic for datepicker as well.

like image 110
rajasaur Avatar answered Oct 16 '22 23:10

rajasaur