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

后端 未结 10 2177
不思量自难忘°
不思量自难忘° 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:37

    You can create your own simple unsafe html binding, of course if you use user input it could be a security risk.

    App.directive('simpleHtml', function() {
      return function(scope, element, attr) {
        scope.$watch(attr.simpleHtml, function (value) {
          element.html(scope.$eval(attr.simpleHtml));
        })
      };
    })
    

提交回复
热议问题