With ng-bind-html-unsafe removed, how do I inject HTML?

后端 未结 10 1997
不思量自难忘°
不思量自难忘° 2020-11-22 04:06

I\'m trying to use $sanitize provider and the ng-bind-htm-unsafe directive to allow my controller to inject HTML into a DIV.

However, I can

10条回答
  •  情歌与酒
    2020-11-22 04:21

    For me, the simplest and most flexible solution is:

    And add function to your controller:

    $scope.to_trusted = function(html_code) {
        return $sce.trustAsHtml(html_code);
    }
    

    Don't forget add $sce to your controller's initialization.

提交回复
热议问题