Filtre angulaire retour html

Je veux utiliser inutilehtml dans angularjs 1.2 . Alors que le filtre sans html fonctionne, avec html il ne fonctionne pas. Ce que je fais:

J'ai ajouté une désinfection angulaire à ma tête html:

<script src="~/Scripts/angular.js"></script> <script src="~/Scripts/angular-sanitize.js"></script> 

Mon module angulaire:

 var myApp = angular.module('myApp', ['ngSanitize']) .filter('convertState', function ($sce) { return function (state) { if (state == 1) { return $sce.trustAsHtml("<strong>" + state + "</strong> special state"); } else { return $sce.trustAsHtml("<strong>"+state + "</strong> normal state"); } } }); 

Mon Html:

 <td><span ng-bind-html="f.state | convertstate"></span></td> 

Edit: mis à jour ng-bind-html-unsafe to ng-bind-html

ng-bind-html-unsafe a été supprimé dans Angular 1.2. Puisque vous désinfectez correctement votre contribution, vous devez simplement utiliser ng-bind-html .

Exemple: http://plnkr.co/edit/0bHeXrarRP7IAciqAYgM?p=preview

Vous pourriez utiliser quelque chose comme

 app.directive('toHtml', function() { return { restrict: 'A', link: function (scope, el, attrs) { el.html(scope.$eval(attrs.toHtml)); } }; }); 

Utilisé comme:

 <p to-html="name | convertState"></p> 

http://plnkr.co/edit/Av2rmeXp7phkDdbYUbxF