i am trying to add rows and columns dynamically into an HTML table with an button on the column header wich pop-up an alert message withe angularJs ng-click.
My columns and rows are added correctly withe jQuery, however, when the button is clicked, it doesn't call my alert function "hello()" in the controler !
here's my jsfiddle link for the issue: https://jsfiddle.net/said_kossouri/cw3f119h/
HTML:
<div ng-app ng-controller="LoginController">
<table border="1" id="mtable" class="table table-striped">
<thead><tr>
<td>Item</td>
<td><button id="deleteColl">Ok</button></td>
</tr></thead>
<tbody><tr>
<td>Some Item</td>
<td><input type="text"/></td>
</tr></tbody>
</table><br/>
<button ng-click="addRow()" id="irow">+ Row</button>
<button ng-click="addCol()" id="icol">+ Column</button>
JS:
function LoginController($scope) {
$scope.addRow = function () {
$('#mtable tbody').append($("#mtable tbody tr:last").clone());
$('#mtable tbody tr:last :checkbox').attr('checked',false);
$('#mtable tbody tr:last td:first').html($('#row').val());
}
$scope.addCol = function () {
$('#mtable tr').append($("<td>"));
$('#mtable thead tr>td:last').html('<button ng-click="hello()">Hello!</button>');
$('#mtable tbody tr').each(function(){$(this).children('td:last').append($('<input type="text">'))});
}
$scope.hello = function () {
alert("HELLO");
}
}