Setroot doesn't work after log in



I’m trying to do an authentication with Azure, it works so far but when I try to set the root page after the user logged in, it doesn’t work and shows me the LoginPage instead of the HomePage.

Here is my login.ts login() function :

login() {
        let ctrl = this;
        let authContext = new Microsoft.ADAL.AuthenticationContext("");


            .then(function (result: Microsoft.ADAL.AuthenticationResult) {
       => {
                    ctrl.isAuthenticated = true;

Could someone help me please ? Thank you


just remove this line and then try again


Hello thanks for your answer, it still doesn’t work :frowning:


have you find any error in console or anything ?


Actually I cannot test in the console cause when I do it says ‘Microsoft is not defined’. It only works on the emulator.

The strange thing is that it works when I put it at the top of the login() function, but it is not what I want cause I want to know if the user is authenticated or not


is this plugin you use ?


Yes it’s this one :slight_smile:


can you show you full ts file code so i can try to understand where is problem.

and first i want to know why you use ?


I followed a tutorial on Microsoft website, I believe he uses zone to update the view based on the authentication success but I’m not sure…

import { Component, ViewChild, NgZone } from '@angular/core';
import { App, NavController } from 'ionic-angular';
import { Http, Headers } from '@angular/http';
import { Platform } from 'ionic-angular';
import { HomePage } from '../home/home';

    selector: 'page-login',
    templateUrl: 'login.html'
export class LoginPage {
    items: Array<any> = [];
    isAuthenticated: boolean = false;

    constructor(private navCtrl: NavController, private zone: NgZone, private http: Http, public appCtrl: App, private platform: Platform) {


    login() {
        if(this.isAuthenticated) {
        let ctrl = this;
        let authContext = new Microsoft.ADAL.AuthenticationContext("");


            .then(function (result: Microsoft.ADAL.AuthenticationResult) {
       => {
                    ctrl.isAuthenticated = true;

                    ctrl.http.get("", {
                        headers: new Headers({ "Authorization": "Bearer " + result.accessToken })
                    }).subscribe(res => {
                        if (res.status == 200) {
                            ctrl.items = res.json().value;
                        } else {
            }, function (err) {


i suggest you to implement code according to ionic doc.because i implemented it one of my project and it run perfectly :ok_hand:.


Man… I suggest I learn to read… Thank you very very very very much