0

I'm building a html block in Angular Controller to avoid the ng-repeat slowness on large data sets.

I'm trying to add a event handler ng-click="clicker()" to the html string and adding it to the dom as below.

document.getElementById("Test").innerHTML="<button ng-click='clicker()'>Click</button>";

when this element is rendered, ng-click is not working as expected - On click, no action is performed. My understanding is that Angular is not aware of this element as this point of time. In that case how do i make angular recognise it as a valid angular event?

I tried to make use if bind-as-html which didn't help.

I'm forced to choose this path due to cons with ng-repeat.

Any help is much appreciated.

BetterLateThanNever
  • 866
  • 1
  • 9
  • 29
  • Search for the many, many questions where this is asked and the answer is some variant over *use `$compile` to ...* – davidkonrad Jan 19 '18 at 18:33
  • Thank you.. poor Googling skills.. Found a post https://stackoverflow.com/questions/14846836/insert-an-angular-js-template-string-inside-an-element – BetterLateThanNever Jan 19 '18 at 18:40

0 Answers0