1

我试图运行任cordovaDialogs没有返回值

$cordovaDialogs.confirm('message', 'title', ['button 1','button 2']) 
    .then(function(buttonIndex) { 

$cordovaDialogs.prompt('msg', 'title', ['btn 1','btn 2'], 'default text') 
    .then(function(result) { 
var input = result.input1; 

所列here, 但在随后的回调的返回值是undefined两种情况。任何想法/修复在这里?

+1

标题是否在你改变它的时候工作,或者它是否说'index.html'?可能是因为Cordova插件没有正确加载,并且它默认为默认的JavaScript对话框。 – Dexter

+0

我明白了,我将不得不再次检查。感谢领先。 –

回答

0

我知道你正在尝试使用$cordovaDialogs,但可能会给$ionicPopup一个试试吗?我对这个插件有更好的运气。它基本上以相同的方式工作。

$ionicPopup.confirm({ 
 
    title: 'Consume Ice Cream', 
 
    template: 'Are you sure you want to eat this ice cream?' 
 
    }).then(function(res) { 
 
    if(res) { 
 
     console.log('You are sure'); 
 
    } else { 
 
     console.log('You are not sure'); 
 
    } 
 
    });

这里是文档吧:https://ionicframework.com/docs/api/service/ $ ionicPopup/

如果您仍然无法得到它的工作,评论,我们会弄明白。我使用了两个插件,我更喜欢离子弹出。

+0

谢谢奥斯汀,但''ionicPopus'是我试图用更原生的外观替换的......他们工作的很好,但现在我看到了他们看起来更好用于UX的对话框。 –

+0

了解。只是想确保你知道另一种选择。好吧,让我们弄清楚为什么Dialog无法正常工作。你可以运行这个: 'var confirm = $ cordovaDialogs.confirm('message','title',['button 1','button 2']); (function(buttonIndex){alert(buttonIndex); )};'' –