Demo: (be sure and open console)
http://jsfiddle.net/michaelnatkin/2Vf8L/4/
The workaround is the same, I use a little cache to make sure I return the same object, but this should clearly be fixed in angular core.
Here's the offending code:
HTML:
<div ng-controller="BugCtrl">
<div to-infinity value="getValue()"></div>
JS:
angular.module('fun', [])
angular.module('myApp', ['fun']).directive('toInfinity',
template: "<p ng-bind-html='value'></p>",
function BugCtrl($scope, $sce) {
$scope.getValue = function() {
return $sce.trustAsHtml('<h1>badass</h1>');
Workaround (used in lieu of $sce.trustAsHtml)
this.trustButVerify = (value) ->
this.converted[value] || (this.converted[value] = $sce.trustAsHtml(value))