jose jose - 1 year ago 136
jQuery Question

ng-change not trigger in IE 11 in angularjs

hi all i am using

angularjs
working with
datepicker
functionality input type date is not working in IE so i am using
jquery
and
css
to get date picker it's working fine but i am not able to trigger the
ng-change
event in IE here i attached my fiddle help how to solve this anyone help

NOTE:Check fiddle in IE 11

Fiddle

Answer Source

Internet Explorer 11 does not currently support <input type='date'> as you already trying to find a work around. You may use datepicker onSelect and update your model. You can fire change function manually. So that you can collect both changes from HTML5 Date supported browsers and others.

You can find the fiddle here

function LoginController($scope) {
    $scope.changeDetected = function() {
        console.log($scope.date);
    }

    if ($('#test')[0].type != 'date') $('#test')
        .datepicker({
            onSelect: function(date) {
                $scope.date = date;
                $scope.$apply();
                $scope.changeDetected(date);
            }
        });
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div ng-app ng-controller="LoginController">
	<input type="date" id="test" ng-model="date" ng-change="changeDetected()"/>
  {{date}}
</div>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download