Reputation: 253
I'm making a html code with angular.element(document).find(id).html(code)
that there is a ng-click and ng-change in code
var. When it writes the html code, it is supposed to work correctly, analysing the html code generated:
Code generated using angular.element:
<a style="cursor:pointer" title="Atualizar" ng-click="atualizarHistorico(303456)"><i class="mdi-action-autorenew small"></i></a>
But when I click in the button, it is not executing the function atualizarHistorico()
I'm generating something like this:
var return = '<a style="cursor:pointer" title="Atualizar" ng-click="atualizarHistorico(303456)"><i class="mdi-action-autorenew small"></i></a></div>';
angular.element(document).find('#' + id).html(return);
Only in this situation is not working, that the html code with ng-click
and ng-change
are generated by angular.element
.
Upvotes: 0
Views: 193
Reputation: 10526
If you must append the HTML, you need to get access to the $compile
service. Then compile the HTML, and link it to the scope that has the functions you want to execute:
$scope.atualizarHistorico = function(...
var return = // HTML
var compiledAndLinked = $compile(return)($scope);
angular.element(document).find('#' + id).html(compiledAndLinked);
Upvotes: 2