gpt4 book ai didi

javascript - 我可以在 mdDialog 中添加变量或函数吗?

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

我想向我的 mdDialog 添加一个变量或函数。我不确定如何创建自定义 mdDialog,我是 angularjs 的新手。

这是我的 mdDialog:

vm.dialog_up = function() {
vm.dis = true;
alert = $mdDialog.alert()
.title('Attention, ')
.content('Do you want to edit your Information?')
.ok('Close');


$mdDialog
.show( alert )
.finally(function() {
alert = undefined;
});
}

我可能想为 .ok 按钮添加一个功能。

最佳答案

JavaScript 是一种非常自由的语言,它允许您向对象添加属性和方法。例如:

 var modal = {};

modal.x = 5;//this assigns the value of `5` to the newly attached property `x`

modal.testMethod = function() {
//Do something here
}

附言:尽管就我个人而言,我认为修改框架对象会导致副作用。

关于javascript - 我可以在 mdDialog 中添加变量或函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31955526/

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