angularjs - How do I make angular.js reevaluate / recompile inner html? -


i'm making directive modifies it's inner html. code far:

.directive('autotranslate', function($interpolate) {     return function(scope, element, attr) {       var html = element.html();       debugger;       html = html.replace(/\[\[(\w+)\]\]/g, function(_, text) {         return '<span translate="' + text + '"></span>';       });       element.html(html);     }   }) 

it works, except inner html not evaluated angular. want trigger revaluation of element's subtree. there way that?

thanks :)

you have $compile inner html like

.directive('autotranslate', function($interpolate, $compile) {     return function(scope, element, attr) {       var html = element.html();       debugger;       html = html.replace(/\[\[(\w+)\]\]/g, function(_, text) {         return '<span translate="' + text + '"></span>';       });       element.html(html);       $compile(element.contents())(scope); //<---- recompilation      }   }) 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -