Escape HTML text in an AngularJS directive

后端 未结 9 902
执念已碎
执念已碎 2020-12-05 07:12

Is there an angular JS command that will do HTML escaping on text? I am processing a custom directive and have need to escape some of the output which it generates.

9条回答
  •  难免孤独
    2020-12-05 07:58

    You can implement filter like this:

    app.filter('escape', escape);
    
     function escape() {
        return function (html) {
          return angular.element('
    ').text(html).html();
        };
      }
    

提交回复
热议问题