app.module.ts
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule,Platform } from 'ionic-angular';
import { HttpBackend, HttpXhrBackend } from '@angular/common/http';
import { NativeHttpModule, NativeHttpBackend, NativeHttpFallback } from 'ionic-native-http-connection-backend';
@NgModule({
declarations: [
MyApp,HomePage,Login,Logout
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp,{
mode: 'ios',
backButtonText: ''
}),
//HttpModule,
//HttpClientModule,
NativeHttpModule,
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,HomePage,Login,Logout
],
providers: [
GoogleMaps,StatusBar,SplashScreen,LoginUser,UserData,AddRecent,
//AppUpdate,
{provide: ErrorHandler, useClass: IonicErrorHandler, HttpBackend, useClass: NativeHttpFallback, deps: [Platform, NativeHttpBackend, HttpXhrBackend]}
]
})
login.ts
submitForm(value: any):void{
let datas = {
email:value.email,
password:value.password,
product_session:values[0]
};
this.loginUser.loginUserAll(datas)
.subscribe(
data => {
console.log(JSON.stringify(data));
let alert = this.alertCtrl.create({
title: JSON.stringify(data),
subTitle: 'Data found',
buttons: ['Close']
});
alert.setMode("ios");
alert.present();
this.nav.setRoot(HomePage);
},
error => {
let alert = this.alertCtrl.create({
title: JSON.stringify(error),
subTitle: 'Data not found',
buttons: ['Close']
});
alert.setMode("ios");
alert.present();
});
}
login providers
import { Injectable } from '@angular/core';
import { HTTP } from '@ionic-native/http';
import { Platform } from 'ionic-angular';
@Injectable()
export class LoginUser {
data:any;
constructor(
private platform: Platform,
private nativeHttp: HTTP,
) { }
loginUserAll(data:any) {
this.platform.ready().then(() => {
return this.nativeHttp.post('http://btrc.urbanitsolution.com/api/login.php', data);
});
}
}
when i use “ionic serve --lab” then
error shows