Search code examples
angularjsng-bind-html

Angular.js - ngBindHtml changes between 1.2.0-RC2 and 1.2.0-RC3


Upon updating from angular 1.2.0-RC.2 to 1.2.0-RC.3 I noticed a breaking change triggered by changes to how ngBindHtmlDirective parses scope data (via this change). What I do is fetch a piece of SVG and then display it (SVG is valid and all that).

I have this bit of template markup:

<div ng-controller="MainCtrl">
  <div ng-bind-html="svg"></div>
</div>

And some logic on my app that requests the SVG from the server and then assigns it to $scope:

app.controller('MainCtrl', ['$scope', '$sce', 'API', function($scope, $sce, API) {
  API.getSVG().then( function(resp) {
    $scope.svg = $sce.trustAsHtml(resp.data.svg);
  });
}]);

This used to work on RC2 but doesn't anymore on RC3. Any idea what I'm doing wrong? thanks.


Solution

  • I set up a simple jsFiddle and it works fine with Angular 1.2.0-RC3 up to 1.2.4.

    JS

    $scope.svg = $sce.trustAsHtml('<svg xmlns="http://www.w3.org/2000/svg"><circle r="50"/></svg>');