0

I have a directive in angularjs, and success to use it like below:

<div my-directive my-data="{}"></div> 

can show <div>Hello</div>

When I load it from an ajax call. For example, my data returned from ajax call:

$scope.ajaxData = {title: 'Title', data = '<div>load from directive like this: <div <div my-directive my-data="{}"></div></div>'}  

and in my template.

<div>Title: <span>{{ajaxData.title}}</span></div>
<div ng-bind-html="ajaxData.data"></div>

But it not bind to directive, just show html code:

 <div my-directive my-data="{}"></div>

Would you please tell me how to bind the directive from text like my case

Thank you very much.

akari
  • 149
  • 9
  • Are you missing a module reference? – Casey Sep 20 '16 at 18:13
  • Possible duplicate of [AngularJS - Compiling dynamic HTML strings from database](http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database) – George Kagan Sep 20 '16 at 18:13
  • You need to pass it through the $compile service, see http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database – George Kagan Sep 20 '16 at 18:15

0 Answers0