我有一个datatable,其中我使用x按钮创建了一些标签,当用户点击它时,我会显示带有通过html传递的参数的模态,然后如果用户确认模态,我必须调用一个Web服务URL中的此参数。 我使用bootstrap和AngularJS。 在我的数据表代码中,我有:
var user;
var s="";
for (user in row.users)
s += '<span class="tag label label-info"><span>'+row.users[user]+'</span><a>'
+'<i id="deleteUserFleet" data-toggle="modal" data-id="'+row.users[user]+'" data-target="#deleteUserFleetModal" class="remove glyphicon glyphicon-remove-sign glyphicon-white"></i></a></span>';
return s;
使用
捕捉参数I&#39; mapp.controller('createFleetController',['$scope','$http', function($scope, $http) {
//Show username in modal before delete his management fleet
$(document).on("click", ".remove", function () {
$scope.username= $(this).data('id');
});
在我的HTML模式代码中我有
<div class="modal" id="deleteUserFleetModal">
<div class="modal-dialog">
<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">Delete user from fleet</h4>
</div>
<div class="modal-body">
<div class="box-body">Are you sure to remove <label>{{username}}</label> management from fleet?</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left"
data-dismiss="modal">Cancel</button>
<button class="btn btn-danger btn-ok"
data-ng-click="deleteUserFleet(username)" id="deleteUserFleetButton">Delete</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
但是我无法在我的页面中看到用户名,如果我删除了document.on事件它可以工作,但我需要将变量关联到按钮点击。 我该怎么做?感谢