我在函数A中定义了$ modal.open({{..})并返回结果。 然后我在其他功能中使用它,我想在其他功能中关闭弹出窗口。我这样做了吗?
例如:
function A( x, y)
{
var a = $modal.open({{..})
return a.result ;
}
function B ( z,w,t)
{
// using function A to open the modal
A(x1, y1).then(
function (result1){
// I want to close the popup window here
});
}
答案 0 :(得分:0)
我们添加了“ isOpen ”变量,默认为。当用户调用功能A时, true 值将分配给它。 每当用户调用另一个函数时,我们检查isOpen值,然后模型对象将关闭。 你可以试试这个:
var isOpen=false;
function A( x, y)
{
var a = $modal.open({{..});
isOpen=true;
return a.result ;
}
function B ( z,w,t)
{
A(x1, y1).then(
function (result1){
if(isOpen){
$model.close(); // close popup window here:
}
});
}