Insert HTML into view from AngularJS controller

前端 未结 18 2120
Happy的楠姐
Happy的楠姐 2020-11-21 06:00

Is it possible to create an HTML fragment in an AngularJS controller and have this HTML shown in the view?

This comes from a requirement to turn an

18条回答
  •  我寻月下人不归
    2020-11-21 06:27

    here is the solution make a filter like this

    .filter('trusted',
       function($sce) {
         return function(ss) {
           return $sce.trustAsHtml(ss)
         };
       }
    )
    

    and apply this as a filter to the ng-bind-html like

    and thank to Ruben Decrop

提交回复
热议问题