【问题标题】:AngularJS 1.1.5, Internet Explorer and ng-show with objects (Bug)AngularJS 1.1.5、Internet Explorer 和带有对象的 ng-show(错误)
【发布时间】:2013-12-30 05:09:45
【问题描述】:

最近我的应用程序出现了一个错误。显示了一个框,但它不应该显示。它是这样初始化的:

<div ng-show="NewGroup">...</div>

幕后

$scope.NewGroup = null;

但是 Internet Explorer(9 和 10)非常顽固,总是显示这个框。解决方案是将显示/隐藏链接到 $location 对象。

有人遇到过这个问题吗?处理它的最佳方法是什么?是 IE 错误还是 Angular 错误?

【问题讨论】:

    标签: internet-explorer angularjs


    【解决方案1】:

    我总是添加 hide 类以确保在加载时隐藏元素,同时添加 css 类作为页面的内联样式:

    <style>
        .ng-hide { display: none!important; }
    </style>
    ...
    <div ng-show="NewGroup" class="ng-hide">...</div>
    

    【讨论】:

    • 我认为更合适的方法是 ng-cloak,但我可能错了。
    • 由于某些原因,ng-cloak 甚至没有隐藏,添加类 ng-hide 只是做了一个完美的工作。谢谢克里斯
    【解决方案2】:

    问题已找到。这个星座:IE 10+、AngularJS 和 textareas 似乎有问题。

    <textarea ng-model="NewGroup.description" placeholder="Some placeholder"></textarea>
    

    计算结果为

    $scope.NewGroup = { description: "" }
    

    并显示该框。自行关闭 textarea 节点即可解决问题。

    <textarea ng-model="NewGroup.description" placeholder="Some placeholder" />
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2013-01-06
    • 1970-01-01
    • 2014-10-10
    • 2013-12-30
    相关资源
    最近更新 更多