Full disclosure: I do not have knowledge of the firebase
system you are utilizing. Nevertheless, achieving your goal in angular code should be simple.
Within your HTML's ng-repeat
section, include a delete function and pass the current iterator's reference. For example:
<div ng-repeat="value in DB">
<div>{{value}}></div><button ng-click="delete(value)"></button>
</div>
Without seeing your repeater code, this is just an assumption for the delete functionality. However, by following this approach, you'll obtain a specific instance to use for alert messages.
If things are still unclear, please share your repeater code.
Additional explanation for OP:
You have a button triggering a model like so:
<md-button class="md-raised md-warn" type="button" data-toggle="modal" data-target="#deleteModal"><i class="material-icons">delete_forever</i></md-button>
In your modal, you have this repeater:
<div class="modal-body">
<h4 class="text-center" ng-repeat="value in DB">Are you sure you want to delete <strong><em>{{value.name}}</em></strong>?</h4>
</div>
The issue lies in repeating all values from your DB using ng-repeat="value in DB"
. Instead, retrieve the clicked value from your button. You can achieve this by adding a click listener on your md-button
, like so:
<md-button class="md-raised md-warn" type="button" data-toggle="modal" data-target="#deleteModal" ng-click="getValueToDelete(value)"><i class="material-icons">delete_forever</i></md-button>
This function captures the value, which you can then store somewhere in your scope. In this case, it is stored in rootScope, but consider using a different method.
$scope.getValueToDelete = function(value){
$rootScope.valueToDelete = value
}
In your modal, only utilize this stored value instead of ng-repeat="value in DB"
. It should look something like this:
<div class="modal-body">
<h4 class="text-center">Are you sure you want to delete <strong><em>{{valueToDelete.name}}</em></strong>?</h4>
</div>
By implementing this method, you will display only one value in your modal. Hopefully, this clarifies things for you now.