Search code examples
twitter-bootstrapangularjsangularjs-scopeangularjs-ng-repeatangular-strap

AngualrJS: How to I pass the data to bootstrap modal?


Here is the plunker - http://plnkr.co/edit/iwvjJcUurUW2AvkDArfz?p=preview

I am using Modal from http://mgcrea.github.io/angular-strap/

I want to pass the transaction-id to delete function, how is this achievable using AngularJS?

Thank you


Solution

  • On the ng-click of the modal's delete button:

    ng-click="modal.saved=true;delete(transaction.id);hide()"
    

    Delete function:

     $scope.delete = function(id) {
       alert(id);
      }
    

    Working plunkr: http://plnkr.co/edit/lzKAjCyIySoz45r56YjL?p=preview

    I believe the strap inherits the current scope so you just pass in the transaction id (or you could pass in the entire transaction object) to the delete function.