Repeat Style Attribute in AngularJS Directive

I have an AngularJS directive that points replace: trueand template: <span style="color: red;"></span>. Whenever I use a directive in its layout, it seems that the contents of an attribute styleis repeated in the DOM: <span style="color: red;;color: red;"></span>. Is this a bug in AngularJS, or am I doing something wrong here?

Here is Plunk that demonstrates the problem: http://plnkr.co/edit/UMhmjGS3XW84d7zctujo

+3
source share
1 answer

I do not know what causes this, but the list of possible solutions does not hurt.

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {$scope.style={color:red};);

app.directive('myDirective', function() {
  return {
    replace: true,
    template: '<span ng-style="style" class="my-test-class">something!</span>'
  };
 });

See: ngStyle

+1
source

All Articles