使用大括号的 Internet Explorer 上的 AngularJS 数据绑定问题

AngularJS Data Binding issue on Internet Explorer using Curly Braces

本文关键字:上的 Explorer AngularJS 数据绑定 问题 Internet      更新时间:2023-09-26

我在这里做错了什么?我已经通读了IE兼容性指南,但没有提到使用{{}}标签的数据绑定。这在其他浏览器上工作正常,但在IE(包括IE9)中失败。

http://jsfiddle.net/yMgQ8/1/

.HTML:

<html ng-app class="ng-app">
    <head></head>
    <body>
        <div ng-controller="Controller">
            <p>{{test}}</p>
        </div>
    </body>
</html>

JavaScript:

function Controller($scope) {
    $scope.test = "Hello world";
}

我尝试添加兼容性指南中提到的步骤,但这似乎并不能解决它,除非我错过了一些明显的东西!

它应该输出"Hello world",但在IE上它输出{{test}}。

非常感谢。

问题似乎不是角度问题,而是 jsfiddle

http://plunker.no.de/BL97Av/这在IE9中有效

此外,IE7或IE8兼容性您只能靠自己。

供将来参考; 在 html 元素中添加 id 属性解决了我的问题。在您的情况下,这意味着将代码更改为:

<html ng-app id="ng-app" class="ng-app">