繁体   English   中英

在Angular Js中更改确认对话框按钮的文本

[英]Change confirm dialog box button's text in Angular Js

首先要提一下,我是Angular JS的新手。 我实现了以下代码,因为我想更改按钮文本(默认按钮名称为“ Ok”和“ Cancel”)。即,将“确定”按钮文本更改为“是”,将“取消”按钮文本更改为“否”模态弹出窗口。 还有其他方法可以实现吗? 它已经在所有浏览器中兼容。

  $scope.sectionLoad = function (formId, sectionId, parentIndex, index){

        if(confirm("Save data?")){
                $scope.submit($scope.form, pageId, sectorId);
        }
        $scope.search = false;
        $scope.sectionDataLoad(formId, sectionId, parentIndex);

  };

简而言之-您不能。 没有肯定的方法可以更改confirm()对话框中的按钮。 您需要创建一个自定义对话框,并使用它来代替confirm()

感谢http://myclabs.github.io/jquery.confirm/

$ scope.loadData =函数(Id,sectionId,parentIndex){

                $.confirm({
                    title:"Save confirmation",
                    text: "Do you want to save the section data ?",
                    confirm: function (button) {
                        $scope.submit(Id, sectionId, parentIndex, index, 2);
                        $scope.search = false;
                        $scope.sectionLoad(Id, sectionId, parentIndex, index);
                        alert("Section Data Saved.");
                    },
                    cancel: function (button) {
                        $scope.sectionLoad(formId, sectionId, parentIndex, index);
                        alert("Section data not saved");
                    },
                    confirmButton: "Yes",
                    cancelButton: "No"
                });   
    };

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM