ionViewLoaded() not firing

I tried using the ionViewLoaded function to set a class on page load but it’s not firing. So I tried just logging a message. It still doesn’t work. What am I doing wrong?

import {IONIC_DIRECTIVES, NavController, ViewController} from 'ionic-angular';
@Component({
    selector: 'my-component',
    directives: [IONIC_DIRECTIVES],
    template: '<button class="{{dynamic-class}}">Hello</button>'
})

export class myComponentClass {

public constructor() {}

    ionViewLoaded() {
        console.log("who lives in a pineapple?");    
    }
}

This is only available in the latest nightly release, so you probably do not have access to this ATM.

Tried in beta.9, ionViewLoaded still not firing.

Same ^ … i have the global ionic up to date and the most recent version of the conference app and still no dice.

Please provide solution for this.

Can’t you use ionViewDidEnter?

Nope its working.

stephan kristyn

For anybody new coming to this, ionViewLoaded() is no longer a valid lifecycle event.

See https://ionicframework.com/docs/v2/api/navigation/NavController/#lifecycle-events for a full list of events. It seems that what was ionViewLoaded is now ionViewDidLoad.

5 Likes