The table footer is used to add a new record to the table. After adding by clicking button, the new record is actually added to the table body but up to a second, after that the entire page is reloaded and the inserted record disappears.
- Table is created correctly from the prepared data array.
- Deleting records works fine.
Where can I have a problem? I don't want to have page reloads.
Table:
<table class="table">
<thead>
<tr>
<th>Nazwa tchnologii</th>
<th>Poziom zaawansowania</th>
<th>-</th>
</tr>
</thead>
<tfoot>
<tr>
<!--Text for new record-->
<th><input type="text" ng-model="nazwaTechnologii" class="form-control"></th>
<!--Button to add-->
<th><button ng-click="dodaj()" class="btn btn-success btn-sm">Dodaj!</button></th>
</tr>
</tfoot>
<tbody id="cialoTabeli">
<tr ng-repeat="technologia in technologie track by technologia.id" id="{{technologia.id}}">
<td>{{technologia.nazwa}}</td>
<!--Button to remove-->
<td><input type="button" ng-click="usunTechnologie(technologia.id)" class="btn btn-danger btn-sm">Usuń!</input></td>
</tr>
</tbody>
</table>
Piece of code JavaScript/AngularJS:
var indeks = 5;
$scope.dodaj = function () {
$scope.technologie.push({ 'id': ++indeks, 'nazwa': $scope.nazwaTechnologii});
$scope.nazwaTechnologii='';
};
$scope.technologie = [ //prepared values
{"id":1,"nazwa":"C++"},
{"id":2,"nazwa":"java"},
{"id":3,"nazwa":"Python"},
{"id":4,"nazwa":"C"}
];