gpt4 book ai didi

javascript - 如何使用 AngularJS 在 SweetAlert 中获取单选按钮值

转载 作者:行者123 更新时间:2023-11-30 12:00:05 25 4
gpt4 key购买 nike

我想使用 Sweet Alert 在 Angularjs 中获取单选按钮值。有没有办法获取选定的单选按钮值。我正在使用 SweetAlert v1.1.3ngSweetAlert 指令。

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

最佳答案

给你 - http://jsbin.com/lonotipeba/edit?js,output

我认为 sweetAlert 将 display:none 应用于输入元素。对不起,大单选按钮,你可以用你的 CSS 来控制。当您单击下载按钮时,您将在 JS 警报中看到 radio 的值。

您可以在 SweetAlert 中传递一个函数来实现您的目标。

P.S 点击 Run with JS 按钮可以看到 sweetAlert 。

关于javascript - 如何使用 AngularJS 在 SweetAlert 中获取单选按钮值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36841836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com