AngularJS: Using $compile on html that contains directives with templateurl

前端 未结 2 1655
温柔的废话
温柔的废话 2020-12-30 15:01

I have a legacy application that has some content inserted into the DOM via jQuery. I would like the legacy parts of the codebase to be responsible for compiling the html th

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 15:34

    Append the element to the target first, then compile it.

    html = angular.element(html);
    target = angular.element(target);
    target.append(html);
    html = $compile(html)($scope)
    

    http://jsfiddle.net/f3dkp291/16/

提交回复
热议问题