Ng-click won't work if the element is appended by jQuery

Hi :smile:
i’m in trouble… i’ve a script that creates and append some divs to a ionic tab content.
The problem is that if i use ng-click this won’t to call my $scope.function… why?

If your adding the divs into the tabs via a directive, then have you tried using angualrs $compile method?

Even if you’re not using a directive you do need to compile is. For angular to watch those click events it has to know they exist. There are a lot of resources on $compile but that’s probably what you’re gonna have to look at. I would see if you can also try not using jQuery but possibly use angulars template functions like ng-repeat maybe? It might work easier than having to re-compile the template every time it changes.

Thank you, this works perfectly!! $compile(myHtml)($scope);

1 Like