I've been searching for a solution to this problem I'm having, but haven't found anything that works for my particular case. I am working on an Ionic 2 application and I am working on some authentication stuff for my login screen. The purpose of this file is to add backend functionality to the front end code I wrote (refer to my login.html file on the github link below). I was following the tutorial on this website: https://devdactic.com/login-ionic-2/
The problem I am having is that for certain functions, which will be marked in my code, I am getting a "Promise returned from (function) is ignored" which stops the code from functioning entirely. It doesn't come up as a compile error, but instead it is a runtime error that is:
Runtime Error Uncaught (in promise): Error: No provider for Http! Error at d
I am really not sure what this means, so any insight would be very helpful. If needed, I can provide a picture of the full error.
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
loading: Loading;
registerCredentials = { email: '', password: ''};
constructor(public navCtrl: NavController, private auth: AuthService, public navParams: NavParams,
private alertCtrl: AlertController, private loadingCtrl: LoadingController) {}
public createAccount() {
this.navCtrl.push('RegisterPage'); //Promise ignored error
}
public login() {
this.showLoading();
this.auth.login(this.registerCredentials).subscribe(allowed => {
if (allowed) {
this.navCtrl.setRoot('HomePage'); //Promise ignored error
} else {
this.showError("Access Denied");
}
},
error => {
this.showError(error);
});
}
showLoading() {
this.loading = this.loadingCtrl.create({
content: 'Please wait...',
dismissOnPageChange: true
});
this.loading.present(); //Promise ignored error
}
showError(text) {
this.loading.dismiss(); //Promise ignored error
let alert = this.alertCtrl.create({
title: 'Fail',
subTitle: text,
buttons: ['OK']
});
alert.present(prompt); //Promise ignored error
}
}
I am just not sure what is causing this problem, and it is causing my code to crash entirely and won't even load my UI. If you need to look at some of the other files, the rest is on my github, this particular file is located in /src/pages/login.
The rest of the files: https://github.com/jparr721/Badmeat/tree/master/BadMeat-Ionic/FirstBuild/src
You probably figured it out already but try changing the public to private in your code over here:
constructor(public navCtrl: NavController,
try:
constructor(private navCtrl: NavController,
I'm not sure if this will fix your problem but try adding the following to your app.module.ts file
import { HttpModule } from '@angular/http';
it may fix your http provider error you will also have to add it to imports in the same file
imports: [
BrowserModule,
HttpModule,
CloudModule.forRoot(cloudSettings),
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],