Good evening I have this method
$scope.register_popup = function(id, name)
{
for(var iii = 0; iii < popups.length; iii++)
{
//already registered. Bring it to front.
if(id == popups[iii])
{
Array.remove(popups, iii);
popups.unshift(id);
$scope.calculate_popups();
return;
}
}
var element = '<div class="popup-box chat-popup" id="'+ id +'">';
element = element + '<div class="popup-head">';
element = element + '<div class="popup-head-left">'+ name +'</div>';
element = element + '<div class="popup-head-right"><a href="javascript:;" ng-click="close_popup(\''+ id +'\');">✕</a></div>';
element = element + '<div style="clear: both"></div></div><div class="popup-messages"></div></div>';
document.getElementById("chat").innerHTML = document.getElementById("chat").innerHTML + element;
popups.unshift(id);
$scope.calculate_popups();
}
I have a dynamically created div. Look at this line:
element = element + '<div class="popup-head-right"><a href="javascript:;" ng-click="close_popup(\''+ id +'\');">✕</a></div>';
In ng-click, I call another method, which in this case would be this:
$scope.close_popup = function(id)
{
for(var iii = 0; iii < popups.length; iii++)
{
if(id == popups[iii])
{
Array.remove(popups, iii);
document.getElementById(id).style.display = "none";
$scope.calculate_popups();
return;
}
}
}
Only nothing happens, even if I put a console.log in this method does not appear anything, I believe it is because it is created dynamically. How can I resolve this?