oitozero / ngSweetAlert

AngularJS wrapper for SweetAlert
MIT License
616 stars 160 forks source link

How to get radio button value in SweetAlert with AngularJS #55

Open essivision opened 8 years ago

essivision commented 8 years ago

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");
    }
});
fedemenseguez commented 7 years ago

I have the same issue trying to use a combobox.

marvinhosea commented 6 years ago

html is depreciated

jeremylzn commented 4 years ago

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