Compiling dynamic HTML strings from database

前端 未结 5 1349
花落未央
花落未央 2020-11-22 02:14

The Situation

Nested within our Angular app is a directive called Page, backed by a controller, which contains a div with an ng-bind-html-unsafe attribute. This is

5条回答
  •  离开以前
    2020-11-22 02:51

    Found in a google discussion group. Works for me.

    var $injector = angular.injector(['ng', 'myApp']);
    $injector.invoke(function($rootScope, $compile) {
      $compile(element)($rootScope);
    });
    

提交回复
热议问题