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
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:
<div id="targetElmForApp" ng-app="myApp"></div>
see:
http://docs.angularjs.org/api/angular.bootstrap
http://docs.angularjs.org/guide/bootstrap
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);
});