I have an AngularJS phonegap application, where the HTML is just a blank table that is being filled up dynamically by JS Ajax. Ajax brings the required data and fills the table by using innerHTML. In my case, the table is filled with multiple buttons and each button has an ng-click method name:
$.ajax({
type: 'GET',
dataType: 'json',
url: 'SAMPLEURL'+tID,
contentType: 'application/json;charset=utf-8',
success: function(response){
var reqObject = JSON.parse(response);
var tableHtml = "";
for(i = 1;i<reqObject.object.length; i++)
{
var variant = reqObject.variants[i];
tableHtml += "<tr><td>";
tableHtml += "<button type='button' ng-click=\"calculateQuantity();\" class='buttonStandard' id='"+variant.Id+"' style='padding:10px 15px 20px 15px; width:100%;margin-top:-10px;'>";
tableHtml += "<div style='height:40px'><h4>"+variant.Name+"</h4></div>";
tableHtml += "</button>";
tableHtml += "</td></tr><tr><td><br /></td></tr>";
}
document.getElementById("tableSelection").innerHTML = tableHtml;
$scope.calculateQuantity = function() {
alert('test');
};
},
error: function(xhr){
alert('Failed to bring Variants');
}
});
As you can see from the code above, I am also adding a method to the scope, called calculateQuantity and it should send an alert with 'test' when a user clicks on a button. Unfortunately this is not happening, anyone knows what I might be doing wrong?