 <p>This works for me </p> <pre><code>.directive('updateinfo',['$compile', function($compile) { function link(scope, element, attrs) { function update(){ var str = '&lt;input type="text" ng-model="log1" /&gt;'; element.html(str); } update(); element.replaceWith($compile(element.html())(scope)); } return { link: link }; }]); </code></pre>