ngSweetAlert
ngSweetAlert copied to clipboard
How to get radio button value in SweetAlert with AngularJS
I want to use Sweet Alert
for get radio button value in Angularjs. Is there a way to get selected radio button value. I am using SweetAlert v1.1.3
anf ngSweetAlert
directive.
SweetAlert.swal({
title: "Please Select:",
text: '<form> <div class=""> <input type="radio" name="csvSelect" id="radio1" ng-model="radioValue" ng-value="1" > <label for="radio1"> Whole records </label> </div> <div class=""> <input type="radio" name="csvSelect" id="radio2" ng-model="radioValue" ng-value="2" ng-click="getVal()"> <label for="radio2"> Selected records </label> </div></form>',
html: true,
showCancelButton: true,
confirmButtonText: "Download it!",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: true,
showLoaderOnConfirm: true
},
function (isConfirm) {
if (isConfirm) {
SweetAlert.swal("Deleted!", $scope.radioValue, "success");
}
});
I have the same issue trying to use a combobox.
html is depreciated
Simply to write the html inside the property "html" It's work for me
var text_html = '
' SweetAlert.swal({ title: "Please Select:", html: text_html, showCancelButton: true, confirmButtonText: "Download it!", cancelButtonText: "Cancel", closeOnConfirm: false, closeOnCancel: true, showLoaderOnConfirm: true }, function (isConfirm) { if (isConfirm) { SweetAlert.swal("Deleted!", $scope.radioValue, "success"); } });