我尝试在登录屏幕加载时显示弹出窗口。我如何在离子中做到这一点?我在controllers.js中的当前代码是:
var myPopup = $ionicPopup.show({
template: 'Do you have your one-time mobile password from the website?',
title: 'Credentials Confirmation',
scope: $scope,
buttons: [
{ text: 'Yes' },
{
text: 'No',
type: 'button-positive',
onTap: function(e) {
myPopup.close();
}
}
}
]
});
答案 0 :(得分:1)
您可以使用以下代码&在其中编写弹出代码。无论是第一次加载还是缓存视图,都会触发此事件。
$scope.$on("$ionicView.enter", function(event, data){
//popup code here
});
参考网址:http://ionicframework.com/docs/api/directive/ionView/
如果您遇到任何问题,请告诉我
<强>更新强>
var myPopup = $ionicPopup.show({
template: 'Do you have your one-time mobile password from the website?',
title: 'Credentials Confirmation',
scope: $scope,
buttons: [
{ text: 'Yes' },
{
text: 'No',
type: 'button-positive',
onTap: function(e) {
myPopup.close();
}
}
]
});