ngSweetAlert
ngSweetAlert copied to clipboard
Access scope from text property
basically i'm trying to add an input field inside the text property and access the scope value :
$scope.deleteTask = function (id, row) {
SweetAlert.swal({
title: "Are you sure?",
text: "<input ng-model='deleteAll' type='checkbox' /><h6>Delete All Tasks Created By The Same Operation </h6> ",
type: "warning",
html : true,
showCancelButton: true,
confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel !",
closeOnConfirm: false,
closeOnCancel: false,
showLoaderOnConfirm: true
},
function (isConfirm) {
if (isConfirm) {
console.log($scope.deleteAll);
} else {
SweetAlert.swal("Cancelled", "Your task is safe :)", "error");
}
});
}
$scope.deleteAll returns undefined :/
Edit :
I figured out that the "divs" were created outside the wrapper which has ng-scope reference,i think it would be great if we can specify the id of the container that we want to use to create the divs inside
Any news on this? +1
since it's created outside the scope there is no ng model, what i've done is that i declared global vars that i update on input change using javascript
Thanks for the workaround, @badreal .
Don't use globals use .bind($scope) and use it within the function as this. instead of $scope.
function (isConfirm) {
if (isConfirm) {
console.log(this.deleteAll);
} else {
SweetAlert.swal("Cancelled", "Your task is safe :)", "error");
}
}.bind($scope));