1

I have created module with controller:

<div ng-app="myModule" ng-controller="myController" >
 <div id="myContainer" data-type="{{type}}"></div>
</div>

Then after some time I need inject into container #myContainer some HTML which have directives inside. HTML code is loaded with ajax.

Code to be injected:

<div ng-repeat="element in elements" data-id="{{element.id}}">
 // some other code heere
</div>

I'm new in AngularJS (I'm using version 1.5.7), but what I have read from documentation is that in some phase of bootstraping angular module/app the mutation observer is binded and I cannot bootstrap the injected code.

So my question is: how to parse the injected code without bootstraping it? And how to pass the elements var?

P.S. I know about ng-include but I cannot use it here.

marverix
  • 7,184
  • 6
  • 38
  • 50
  • Am I missing something here, but isn't ng-if what you need? If you need to display one control and then another one then ng-if will do that for you. – PeterS Jul 29 '16 at 12:44
  • Yes, you are missing. As I said - I'm loading content from ajax. So what I'm looking for is not simple if/else but dynamic parsing/compining/rendering (I don't know how to call it) downloaded HTML template (one of maaaany). – marverix Jul 29 '16 at 12:56
  • 3
    Is this what you are looking for: http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database – PeterS Jul 29 '16 at 13:15
  • Yes! Thanks! I will close this one – marverix Jul 29 '16 at 13:18

0 Answers0