0

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>

<body>
    <div ng-app="myApp" ng-controller="myCtrl">
        <div style="color:{{color}}">Testing</div>
    </div>
    <script>
        var app = angular.module('myApp', []);
        app.controller('myCtrl', function($scope) {
            $scope.color = "#996600";
        });
    </script>
</body>

Color properties not working in IE, but chrome and firefox are working

1

4 Answers 4

2

Instead of using expression using {{}}, use ng-style directive.

<div ng-style="{color: color}">Testing</div>

Angular has issues when using style. Refer

Sign up to request clarification or add additional context in comments.

Comments

1

This is the updated code:

<body>
<div ng-app="myApp" ng-controller="myCtrl">
    <div ng-style="{color:color}">Testing</div>
</div>
<script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
        $scope.color = "#996600";
    });
</script>

As you are using angularJs you need to define ng-style

Comments

1

Try using the ng-style directive:

https://docs.angularjs.org/api/ng/directive/ngStyle

Comments

0

style is HTML attribute where as ng-style in Angular Attribute. So that Please use below notation

<div ng-style="{color:color}">Testing</div>

if want angular Notification

<body>
   <div ng-app="myApp" ng-controller="myCtrl">
      <div ng-style="color:{{color}}">Testing</div>
   </div>
</body>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.