Home:ALL Converter>Manually initializing a dynamic DOM element in AngularJS

Manually initializing a dynamic DOM element in AngularJS

Ask Time:2013-07-01T01:32:44         Author:ustun

Json Formatter

How does one initialize a dom element that is manually inserted to the dom in angular?

angular.bootstrap doesn't seem to work in this case, since I already initialize the app with ng-app. I just want to initialize the new dom element, not the whole app. angular.bootstrap($('#my-new-element'), ['MyApp']) works but is problematic since it creates a new instance of the app on the new dom element instead of adding the new element and controller into the existing app.

I am thinking there must be a way of getting the $compile from the injector and compiling the new element with the html to get the linking function, but not sure what to pass for the scope there.

Author:ustun,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/17393022/manually-initializing-a-dynamic-dom-element-in-angularjs
yy