2017-03-19 129 views
0

我想在用户首次登录时使用$ 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

您可以:

  • 设置一个变量firstTimetrue当用户登录时。
  • 检查firstTime是否为true,然后致电$ionicPopup.show
  • firstTime设置为false后查看是否为true
  • 如果您没有其他地方存储,可以将firstTime存储在Angular服务中。如果您希望firstTime的值即使用户刷新仍然存在,您可以将其存储在localStorage中。例如,检查出angular-local-storage
+0

或者您可以将firstTime存储在localstorage中并从那里检查 – Antonis

+0

这不会持久,并且每当启动应用程序时,firstTime始终为false。使用localStorage作为@Antonis建议是一种方式去 – Ladmerc

+0

谢谢,我更新了我的答案。 –

相关问题