2

I have this button which fires the removefromselected() function when pressed. It does not confirm before firing. How can i add a box or popup which will ask the user to confirm his action. And if the user presses confirm only then the removefromselected() function will fire. How can i do that? Below is my code -

html-

<div class="col-md-6">
     <h4>Reserved Seats</h4>
     You have selected the following dates for {{selectedTrip.from}} to {{selectedTrip.to}}
     <ul class="booked">
        <li ng-repeat='d in selectedDates | orderBy : app.identity | futureDate'>
           {{d | date : 'fullDate'}} {{selectedTrip.arrivalTime}}
           <button class='btn btn-xs btn-warning btn-skinny' style='margin:5px' ng-click='removeFromSelected(d)'>Remove</button>
        </li>
     </ul>
  </div>

the function-

$scope.removeFromSelected = function(dt) {
if ($scope.selectedDatesMap[dt]) {
  $scope.selectedDatesMap[dt].keep = false;
}
$scope.selectedDates.splice($scope.selectedDates.indexOf(dt), 1);
$scope.setDateSelected(new Date(dt), false);

};

hhs
  • 309
  • 1
  • 3
  • 13

1 Answers1

0

From what I understand (can be wrong), you want sort of a popup that asks if the user are sure, and if yes, perform an action, I found this question with this answer:

var result = confirm("Want to delete?");
if (result) {
  //Logic to delete the item
}

This is of course inside another function, that you call with an ng-click

Hope this helps.

Community
  • 1
  • 1
sch
  • 1,368
  • 3
  • 19
  • 35