【问题标题】:Angularjs - IE8 in IE7 modus (and in IE8 compatibility modus) not working properlyAngularjs - IE7 模式中的 IE8(以及 IE8 兼容模式)无法正常工作
【发布时间】:2025-12-31 20:30:01
【问题描述】:

我在使用 Angularjs 1.0.1 版时遇到了一点问题。我创建了一个应用程序并在 IE8 中以 IE7 模式对其进行了测试,它不听 ng-change 或 ng-click,没有测试其他句柄,但至少这两个对我不起作用......(所有其他浏览器都很好)我希望你们能帮助我,或者我在这里遗漏了什么...... IE7/8有特殊处理吗?

这里你看到了控制器:

CalculatorCtrl = function($scope) {
    $scope.btw = 1;
    $scope.input = 0.00;
    $scope.output = 0.00;

    $scope.getBedrag = function() {
        var input = $scope.input;
        var btw = $scope.btw;       
        var output = 0.0;

        if(input != 0) {
            input = parseFloat(input.replace (",", "."));
            var tmp = input+"";
            $scope.input = tmp.replace(".", ",");
        }

        if($scope.isNumber(input)) {
            output = $scope.calculateBedrag(input);

            if(btw == 1) output = output * 1.19;

            $scope.output = output.toFixed(2).replace('.', ',');
        } else {
            //alert('Voer een bedrag in a.u.b.');
            $scope.input = 0;
            $scope.output = 0;
        }
    }
}

在我简单使用的html中:

<input autocomplete="off" ng-model="input" class="x-width" type="text" name="bedrag" value="" ng-change="getBedrag()" />
<input class="x-width" disabled="disabled" type="text" name="bedrag" value="{{output}}" />

希望有人可以帮助我:)

编辑: 好吧,我在 IE7 模式下尝试了 IE Tester,但也没有用。我没有任何装有 real IE7 的机器,所以我无法测试...

【问题讨论】:

    标签: javascript web-applications angularjs


    【解决方案1】:

    还要确保您的应用程序遵循文档中列出的 IE 指南。 http://docs.angularjs.org/guide/ie

    【讨论】:

      【解决方案2】:

      好吧,文档说:

      “基于 Webkit 的浏览器(Safari、Chrome、iPhone、Android、WebOS、 黑莓6)、火狐、IE6及以上。请注意,CSS 仅适用于 IE7 及以上。”

      所以它应该可以正常工作。不过,兼容模式有点奇怪,如果他们在那种模式下进行测试,我会感到惊讶。

      我真的无法想象你为什么需要它在那种模式下工作——如果你在 Intranet 上,你可以通过组策略更改 IE 的设置(据我所知)以使用兼容模式停止​​它.

      【讨论】:

      • 好吧,我在 IE7 模式下尝试了 IE Tester,也没有工作。我没有任何装有 real IE7 的机器...
      【解决方案3】:

      要使其工作,您必须使用类来定义您的 Angular 标记。例如:

      <div class="ng-controller:CalculatorCtrl">

      代替

      <div ng-controller="CalculatorCtrl">

      【讨论】: