Initialize AngularJS controller after append some html into DOM

后端 未结 2 798
盖世英雄少女心
盖世英雄少女心 2020-12-17 02:12

Is there a way how to use $compile from pure javascript? I\'m combinating basic javascript and places where I\'m using Angular and can\'t find a way how to do something like

2条回答
  •  伪装坚强ぢ
    2020-12-17 02:53

    Alternative way from this post: AngularJS + JQuery : How to get dynamic content working in angularjs

            angular.element(document).injector().invoke(function ($compile) {
                    var container = $('#some-dom-element');
                    var scope = angular.element(container).scope();
                    $compile(container)(scope);
            });
    

提交回复
热议问题