【问题标题】:IE11 issue: styles used as angularJS variable doesn't render [duplicate]IE11 问题:用作 angularJS 变量的样式不呈现 [重复]
【发布时间】:2015-11-28 09:49:11
【问题描述】:

HTML

<div ng-app="myApp" ng-controller="myCtrl" style="background:{{hex}}">
        Background-color: {{hex}}
</div>

Javascript

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.hex= "#ff0000";
});

这是 jsFiddle http://jsfiddle.net/2qLwoydd/

当我尝试使用变量作为样式时,它适用于 Chrome 和 FF,但背景颜色(在上面提到的示例中)不适用于 IE11。 感谢您的帮助。

【问题讨论】:

    标签: css angularjs internet-explorer-11


    【解决方案1】:

    使用ng-style 代替{{}} 的样式属性

    标记

    <div ng-app="myApp" ng-controller="myCtrl" ng-style="{'background-color':hex}">
        Background-color: {{hex}}
    </div>
    

    Working Fiddle

    【讨论】:

      猜你喜欢
      • 2018-06-10
      • 2014-06-26
      • 2019-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      • 2014-10-15
      相关资源
      最近更新 更多