Insert HTML into view from AngularJS controller

前端 未结 18 1786
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:51

    on html

    OR

    on controller

    mySceApp.controller("myAppController", function myAppController( $sce) {
    
    this.myCtrl.comment.msg = $sce.trustAsHtml(html);
    

    works also with $scope.comment.msg = $sce.trustAsHtml(html);

提交回复
热议问题