In my current project, for logout I want to add confirmation. For the confirmation I want sweet alert. I found solution for confirmation and sweet alert separately but I am finding it difficult to combine those two. HTML:
<a href="javascript:void(0);" ng-click="Logout()"><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a>
js:
app.controller('LogoutCtrl', ['$scope', '$location', 'localStorageService', function($scope, $location, localStorageService) {
$scope.Logout = function() {
swal({
title: "Are you sure to logout?",
text: "",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes',
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
localStorageService.clearAll();
$location.path('/login');
}
});
}
}]);
I know there can't be function inside another function but I can't find other way round. Instead of angular confirm I want to use sweet alert. Is it possible. Thanks in advance.