IE 11没有触发“ng-change”。 (AngularJS) [英] IE 11 is not triggering "ng-change" (AngularJS)

查看:77
本文介绍了IE 11没有触发“ng-change”。 (AngularJS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我正在使用 angularjs ,使用 datepicker 功能。输入类型日期在IE上不起作用所以我使用 jquery css 来获取日期选择器,它工作正常但是我无法在IE中触发 ng-change 事件,在这里我附上了我的小提琴帮助。帮我解决这个问题。

Hi all I am using angularjs, working with datepicker functionality. Input type date is not working on 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. Help me solving this problem.

小提琴

推荐答案

Internet Explorer 11目前不支持< input type ='date'> 因为你已经在尝试找到一个解决方法。您可以使用 datepicker onSelect 并更新您的模型。您可以手动触发更改功能。因此,您可以从HTML5支持日期的浏览器和其他浏览器收集这两项更改。

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.

您可以找到小提琴这里

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>

这篇关于IE 11没有触发“ng-change”。 (AngularJS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆