@bholub1 wrote:
I have an injectable service (OAuth2 client) and I want to log the user out and redirect them to a LoginPage when their access token is expired and refresh token is invalid/fails (see previous topic on handling refresh tokens here: https://forum.ionicframework.com/t/oauth2-api-calls-and-refreshing-tokens-chaining-observables/46671/5 )
I tried using IonicApp and app.getComponent('root-nav') to get my NavController, and that seemed to work fine, until I tried to call setRoot(LoginPage). Then it barfs and asks for LoginPage to be injectable.
import {IonicApp, NavController, Storage, SqlStorage} from 'ionic-framework'; import {LoginPage} from '../pages/login/login'; @Injectable() export class WAC { constructor(http:Http, app:IonicApp) { this.http = http; this.app = app; } logout() { this.storage.remove('oauth'); let nav = this.app.getComponent('root-nav'); this.nav.setRoot(LoginPage); } }
Thanks!
Posts: 1
Participants: 1