Initialize AngularJS controller after append some html into DOM

后端 未结 2 797
盖世英雄少女心
盖世英雄少女心 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:38

    angular.bootstrap($("#targetElmForApp")[0], ["myApp"]);
    

    Explanation:

    angular.bootstrap(rootElementForApp, arrayOfModulesForTheApp)
    

    The first parameter sets the root element for the app, which is what you would do by using ng-app directive otherwise.

    The second parameters is a list of modules that defines the application. This is typically a single module in which the app is defined.

    So what we did is the same as:

    see:
    http://docs.angularjs.org/api/angular.bootstrap
    http://docs.angularjs.org/guide/bootstrap

提交回复
热议问题