我如何让$ ionicPopup只出现一次然后再出现?

时间:2017-03-19 00:54:15

标签: javascript angularjs ionic-framework

我试图在用户首次登录时使用$ ionicPopup作为快速教程屏幕。登录后,他们永远不需要再次看到该消息。我还没有找到任何关于如何在Ionic Framework中执行此操作的示例。

这是我到目前为止的代码,我将它放在$ timeout函数()中,以便我可以设置超时。

$超时(函数(){     var myPopup = $ ionicPopup.show({

  template: '<h4 class="ion-ios-search-strong"> Choose a store</h4></br><h4 class="ion-coffee"> Select a drink</h4></br><h4 class="ion-wrench"> Customize your coffee</h4></br><h4 class="ion-card"> Pay from your phone</h4></br><h4 class="ion-happy-outline"> Your coffee is ready</h4></br>',
     title: 'How to use Joe',
     // subTitle: 'Your coffee is a few taps away',
     scope: $scope,

      buttons: [
           { text: 'Got it!' },
       ]
 });   

myPopup.then(function(res) {
   console.log('Tapped!', res);
});  

},5000);

1 个答案:

答案 0 :(得分:1)

你可以:

  • 当用户登录时,将变量firstTime设置为true
  • 在致电firstTime之前,请检查true是否为$ionicPopup.show
  • 检查后将firstTime设置为false以查看它是否为true
  • 如果您没有其他地方存储它,您可以将firstTime存储在Angular服务中。如果您希望即使用户刷新,firstTime的值也会保留,您可以将其存储在localStorage中。例如,请查看angular-local-storage