ngSweetAlert icon indicating copy to clipboard operation
ngSweetAlert copied to clipboard

How to get radio button value in SweetAlert with AngularJS

Open essivision opened this issue 8 years ago • 3 comments

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");
    }
});

essivision avatar Apr 25 '16 13:04 essivision

I have the same issue trying to use a combobox.

fedemenseguez avatar Jun 21 '17 14:06 fedemenseguez

html is depreciated

marvinhosea avatar Dec 30 '17 11:12 marvinhosea

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"); } });

jeremylzn avatar Oct 09 '20 12:10 jeremylzn