I need help creating a button that will add rows to a table dynamically when pressed. However, I am encountering an error when trying to call the function in TypeScript (save_row()
).
How can I successfully call the function in TypeScript and dynamically append rows by clicking on the button?
HTML:
<table id="myTable">
<thead>
<tr>
<th>GEOGRAPHY</th>
<th>COUNTRY</th>
<th>STATE</th>
<th>REGULATION</th>
<th>SMS</th>
<th>WEB</th>
<th>EMAIL</th>
<th>OPERATION</th>
</tr>
</thead>
<tbody #ir>
</tbody>
</table>
TypeScript:
var d=geo_Value;
var len=d.length;
var row = this.renderer.createElement('tr');
const col=this.renderer.createElement('td');
row.appendChild(col);
col.outerHTML ="<tr id='row"+len+"'><td
id='name_row"+geo_Value+"'>"+cou_Value+"</td><input type='button'
id='save_button' value='Save' class='save' onclick='save_row("+len+")'>
</td></tr>";
this.renderer.appendChild(this.ir.nativeElement,row);
let idGet=document.querySelectorAll('#save_button');
var myMessage = "it's working";
function save_row(a) {
}