0

I have a pop up tutorial (basically slider) that will show upon first launch in the app. This is what I wrote in the controller.js

  //show first time tutorial
  if(localStorage.getItem("second") != "true")
  {
  $ionicPopup.show({
  template: '<ion-slide-box class="first_tutorial">\
      <ion-slide>\
        <img class="img1" />\
      </ion-slide>\
      <ion-slide>\
        <img class="img2" />\
      </ion-slide>\
      <ion-slide>\
        <img class="img3" />\
      </ion-slide>\
      <ion-slide>\
        <img class="img4" />\
      </ion-slide>\
    </ion-slide-box>',
  scope: $scope,
  cssClass: 'tutorial_popup_dlg',
  buttons: [
    { text: 'Got It' }
  ]
});
localStorage.setItem("second", "true");
  }
  //--show first time tutorial

But it is not working...any suggestions ?

2 Answers2

0

This is because when you are checking condition in if statement then you don't have item second in localStorage

Write your if condition as follow

if(localStorage.getItem("second")==undefined)
Divyesh Savaliya
  • 2,692
  • 2
  • 18
  • 37
0

You need to check if the localstorage item exist. See this for further explanation.

if (localStorage.getItem("second") === null) {
  //...
}
Community
  • 1
  • 1
CESCO
  • 7,305
  • 8
  • 51
  • 83