Protect single tab

I am trying to password protect just a single tab. How do i do that? i was trying to start very basic

If($scope.username != “admin”)
{ $state.go('login) }

but that doesn’t seem to do anything.
There are plenty of app examples that show how to create a login for an entire app, but i only want to protect a single view

I’m still learning ionic and angular… so any help is greatly appreciated

1 Like

You have atleast 2 options here.

  1. Use route resolve, with promise, rejecting or resolving a promise, and then using angular’s statechangesuccess and statechangeerror
  2. add ng-click on <ion-tab> passing state name to it, and then either event.preventDefault(); or state.go(yourPassedState)