admin管理员组文章数量:1434960
I am having a problem in datepicker with ng-change. The ng-change event is not firing when I change the value by "clicking the date" but working when I change the value by "typing the date".
Here's my code.
<input ng-change="date_change();" ng-model="date_to" id="recon-date" name= "date_to" type="text" class="form-control" date-time view="month" auto-close="true" min-view="month" format="MM-DD-YYYY">
I trace the problem by investigating the datepicker.js. I found out (if I'm correct) that the ngModelController.serViewValue() and $render() is not firing the ng-change.
I tried to add scope.$apply() but no luck. I am debugging this for hours and still no progress.
P.S. I don't want to use $scope.$watch() to solve this problem.
Thankss!!
I am having a problem in datepicker with ng-change. The ng-change event is not firing when I change the value by "clicking the date" but working when I change the value by "typing the date".
Here's my code.
<input ng-change="date_change();" ng-model="date_to" id="recon-date" name= "date_to" type="text" class="form-control" date-time view="month" auto-close="true" min-view="month" format="MM-DD-YYYY">
I trace the problem by investigating the datepicker.js. I found out (if I'm correct) that the ngModelController.serViewValue() and $render() is not firing the ng-change.
I tried to add scope.$apply() but no luck. I am debugging this for hours and still no progress.
P.S. I don't want to use $scope.$watch() to solve this problem.
Thankss!!
Share Improve this question asked Feb 19, 2017 at 4:21 aldesabidoaldesabido 1,2882 gold badges18 silver badges38 bronze badges 4- Possible duplicate of angularjs timepicker ng-change – Naghaveer R Commented Feb 19, 2017 at 5:00
- Thanks but I dont want to use $watch event. I have so many date with ngchange and dont want to create $watch in every single one of them. – aldesabido Commented Feb 19, 2017 at 5:33
- Try to use md-datepicker or angular-datepicker.js instead of datepicker.js – Naghaveer R Commented Feb 19, 2017 at 5:46
- Gonna try that. Thanks. – aldesabido Commented Feb 19, 2017 at 8:36
3 Answers
Reset to default 2Without ng-change
, use a watch
$scope.date_to;
$scope.$watch("date_to", function(newValue, oldValue) {
console.log("I've changed : ", to date);
});
Use $apply
, May this will help you.
var scope=angular.element($('#recon-date')).scope();
scope.$apply();
Use this onchange="angular.element(this).scope().photoChange(this)" instead of this ng-change="photoChange(this)"
本文标签: javascriptAngular datepicker not firing ngchangeStack Overflow
版权声明:本文标题:javascript - Angular datepicker not firing ng-change - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745614298a2666302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论