0

I have some html code generated by Angular using put,sample of code:

a.put("ngTagsInput/tags-input.html", '<div class="host" tabindex="-1" 
ti-  transclude-append=""></div>')

However when I attempt to attach any jquery event handler to any of the elements, it does not work. Here is an example of the jquery that i am using:

$(".host").on('click',function(){
    alert('hi');
});

Do I need to compile the HTML code generated by Angular, or is there something im doing wrong with jquery?

Brian Ly
  • 183
  • 1
  • 3
  • 11
  • 3
    DON"T DO THAT. Bind event using angular-way, `ng-event` and compile the html before adding to DOM. If you still want to use jQuery [Event binding on dynamically created elements?](//stackoverflow.com/q/203198) – Tushar Jan 12 '17 at 03:15
  • Listen to @Tushar -- this is not the "Angular way" to do this-- and doing things the Angular way is very important if it is your framework. Check out [this answer](http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background#15012542) for a post "Thinking in AngularJS if I have a jQuery background". – Alexander Nied Jan 12 '17 at 03:17
  • @tushar, anied thanks for the suggestions guys, really appreciate it – Brian Ly Jan 12 '17 at 03:20

0 Answers0