javascript - 如何仅在第一次打开应用程序时在 Ionic 中显示 Controller ?

标签 javascript angularjs ionic-framework

我在 Google 上看到了很多:IonicAngular 的导览、演练和介绍页面,但我无法追踪它是如何的仅在首次打开该应用时显示(之后,除非您删除该应用,否则不会再次显示)

所以我想做的是显示我只创建过一次的 View / Controller /页面,并且仅在应用程序第一次打开时显示。第二次访问时,我不想让人们再看到它。

这可能吗?如果是这样,我该怎么做?有人能指出我正确的方向吗?

最佳答案

在你的 Controller 中使用

if(localStorage.getItem['firstTimeLoad']!='TRUE'){
    localStorage.setItem['firstTimeLoad']='TRUE';
    $state.go('onetime.view'); 
}
else{
    $state.go('your.route');
}

因此,当您的应用首次加载时,您的本地存储将为空。所以它将把你带到你的第一次页面并设置本地存储,这样当你第二次加载应用程序时,条件将不满足。

if(localStorage['firstTimeLoad']!='TRUE'){
    localStorage['firstTimeLoad']='TRUE';
    $state.go('onetime.view'); 
}
else{
    $state.go('your.route');
}

关于javascript - 如何仅在第一次打开应用程序时在 Ionic 中显示 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42659581/

相关文章:

javascript - AngularJS:尝试设置在 ng-options 和输出值中选择的内容,而不是整个对象

javascript - 加载 gtm.js 时网页闪烁

javascript - 针对多个字段的 Angular 搜索过滤器

angularjs - 推送状态在 AngularJS 中显示错误

angular - Ionic 3 - 标签 href 内部链接

angular - 带有Sqlite的Ionic 4-无法读取未定义TypeError : Cannot read property 'then' of undefined的属性 'then'

android - cordova-plugin-ionic-webview - 自定义方案不适用于 Android

javascript:在模块内部不需要使用严格

java - android webview.loadUrl 不会加载另一个网页

javascript - 如何替换正则表达式匹配的字符串的最后一个字符(javascript)