0

I'm building an 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.

halfer
  • 19,824
  • 17
  • 99
  • 186
BetterLateThanNever
  • 886
  • 1
  • 9
  • 31
  • 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