可以引入ui.bootstrap或者popeye
我使用的的是https://pathgather.github.io/popeye/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
$scope.deleteEnvs = function () {
var envs = $scope.selectData;
var message = '';
angular.forEach(envs, function(item){
message = message + item.label
})
var modal = Popeye.openModal({
templateUrl: 'templates/handsome/checkModal.html',
controller: "deleteEnvCheckCtl",
resolve: {
envs: function () {
return envs
},
scope1: function() {
return $scope
}
}
})
}
|
需要注意写一个controller和写一个html,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
app.controller('deleteEnvCheckCtl', function($scope, Popeye, envs, $http, scope1) {
$scope.items = envs;
$scope.sure = function () {
Popeye.closeCurrentModal();
angular.forEach($scope.items, function(item){
var params = {};
params['label'] = item.label;
params['user'] = scope1.currentUser.user_name;
params['message'] = params['user'] + ' deleted in mine'
console.log(params);
$http({
method: 'POST',
url:'xxx',
data: params
}).then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
console.log(response);
});
})
alert("已经删除");
return;
}
$scope.cancel = function () {
Popeye.closeCurrentModal();
return;
}
})
|
如下是我写的html
1
2
3
4
5
6
7
8
9
10
|
<div class="delelteCheck">
<h1>请注意,如下环境将会被删除,删除不可逆,请确认好!</h1>
<ul>
<li ng-repeat="env in items" class="danger"><font size="5" color="red">{{ env.label }}</font></li>
</ul>
<div class="buttons float-right">
<button class="btn btn-primary" ng-click="sure()">确认删除</button>
<button class="btn btn-primary" ng-click="cancel()">取消</button>
</div>
</div>
|