I changed the example to a simple one. I want to call a delete function when I click on "Remove this {{item.id}}" button. The title successfully get the item.id value.
<h4 class="modal-title" id="exampleModalLabel">Do you want to remove {{item.id}}</h4>
But the button doesn't get the item.id value and the function doesn't work. And instead of "Remove this item.id" it's only "Remove this ", and the function doesn't get the parameter too.
<button type="button" id="exampleModalLabel" class="btn btn-primary" ng-click="removeItem(item.id)">Remove this {{item.id}}</button>
What I have is this:
<tr ng-repeat="item in items">
<td>{{item.id}}</td>
<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="{{item.id}}">Remove this item?</button></td>
</tr>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">Do you want to remove {{item.id}}</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" ng-click="removeItem(item)">Remove this {{item.id}}</button>
</div>
</div>
</div>
</div>
//And this javascript
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-title').text('New message to ' + recipient);
modal.find('.modal-body input').val(recipient);
});
I hope the info is enough. If you need some more info, please tell me.