I'm making an app with Ionic that uploads an image to my Firebase storage. When the upload is complete, the app should redirect the user to the WelcomePage. The upload is working, but for some reason the user is not being redirected. Take a look at the end of the code: The console does shows Uploaded, but this.navCtrl.push(WelcomePage) is not working.
upload() {
let storageRef = firebase.storage().ref();
const filename = "profilePic";
const imageRef = storageRef.child(`images/${filename}.jpg`).putString(this.profilepicture, firebase.storage.StringFormat.DATA_URL);
imageRef.on('state_changed', function(snapshot){
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
document.getElementById("percent").innerHTML = "Progresso:" + Math.floor(progress) + "%";
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED:
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING:
console.log('Upload is running');
break;
}
}, function(error) {
// Handle unsuccessful uploads
}, function() {
// Handle successful uploads on complete
console.log('Uploaded');
this.navCtrl.push(WelcomePage);
});
}