我想在Angularjs中使用Sweet Alert
获取单选按钮值。有没有办法获得选定的单选按钮值。我正在使用SweetAlert v1.1.3
anf ngSweetAlert
指令。
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");
}
});
答案 0 :(得分:3)
你去了 - http://jsbin.com/lonotipeba/edit?js,output
我认为sweetAlert将display:none
应用于输入元素。很抱歉大单选按钮,你可以控制你的CSS。当您单击下载按钮时,您将在JS警报中看到无线电的值。
您可以在SweetAlert中传递function
来完成目标。
P.S点击使用JS运行按钮查看sweetAlert。