angularjs timepicker ng-change

筅森魡賤 提交于 2019-12-05 01:47:08

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/17773412/angularjs-timepicker-ng-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!