aldesabido
aldesabido

Reputation: 1288

Angular datepicker not firing ng-change

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!!

Upvotes: 1

Views: 6132

Answers (3)

Hemalatha J
Hemalatha J

Reputation: 1

Use this onchange="angular.element(this).scope().photoChange(this)" instead of this ng-change="photoChange(this)"

Upvotes: 0

user7575867
user7575867

Reputation:

Use $apply, May this will help you.

var scope=angular.element($('#recon-date')).scope();    
scope.$apply(); 

Upvotes: 2

Sajeetharan
Sajeetharan

Reputation: 222532

Without ng-change, use a watch

$scope.date_to;

$scope.$watch("date_to", function(newValue, oldValue) {
    console.log("I've changed : ", to date);
});

Upvotes: 2

Related Questions