Answer the question
In order to leave comments, you need to log in
How to remove elements in Angular?
I wrote the following code that creates DOM elements:
<tr ng-repeat="allowedMac in allowedMacs">
<td class="td-username">{{allowedMac.name}}</td>
<td class="td-ipaddress">{{allowedMac.ip}}</td>
<td class="td-macaddress">{{allowedMac.mac}}</td>
<td class="td-date">{{allowedMac.date}}
<button class="delete-record" ng-click="">❌</button>
</td>
</tr>
Answer the question
In order to leave comments, you need to log in
<button ng-click="removeAddr(allowedMac)">remove</button>
var allowedMacs = [];
function removeAddr(allowedMac) {
$http.delete('/macs/' + allowedMac.mac).then(function (response) {
if (response.success) {
allowedMacs.splice(allowedMacs.indexOf(allowedMac), 1);
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question