У меня есть эта ошибка ниже.Также, когда у меня нет ошибок, мой сетевой провайдер не работает.Может кто-нибудь знает, как решить эту проблему, которая у меня есть много дней назад. Я пробовал некоторые вещи из видео YouTube, но все еще не работает.Везде, где некоторые люди говорят, что это ошибка с ионным 4
Uncaught Error: Can't resolve all parameters for NetworkService: (?, ?, ?).
at syntaxError (compiler.js:486)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:15706)
at CompileMetadataResolver._getTypeMetadata (compiler.js:15541)
at CompileMetadataResolver._getInjectableMetadata (compiler.js:15521)
at CompileMetadataResolver.getProviderMetadata (compiler.js:15881)
at compiler.js:15792
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (compiler.js:15752)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15320)
at JitCompiler._loadModules (compiler.js:34413)
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Geolocation } from '@ionic-native/geolocation';
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder';
import { GoogleMap, GoogleMaps } from '@ionic-native/google-maps';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { IzvjestajPage } from '../pages/izvjestaj/izvjestaj';
import { LoginPage } from '../pages/login/login';
import { NalogPage } from '../pages/nalog/nalog';
import { OtkazPage } from '../pages/otkaz/otkaz';
import { ServicesPage } from '../pages/services/services';
import { RegistrationPage } from '../pages/registration/registration';
import { PeopleServiceProvider } from '../providers/people-service/people-service';
import { LocationAccuracy } from '@ionic-native/location-accuracy';
import { ExtendedDeviceInformation } from '@ionic-native/extended-device-information';
import { Network } from '@ionic-native/network';
import { IonicStorageModule } from '@ionic/storage';
import { NetworkService } from '../providers/network/network';
@NgModule({
declarations: [
MyApp,
HomePage,
LoginPage,
IzvjestajPage,
NalogPage,
OtkazPage,
ServicesPage,
RegistrationPage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
LoginPage,
IzvjestajPage,
NalogPage,
OtkazPage,
ServicesPage,
RegistrationPage
],
providers: [
StatusBar,
HttpClientModule,
Geolocation,
NativeGeocoder,
GoogleMaps,
StatusBar,
LocationAccuracy,
NetworkService,
{provide: ErrorHandler, useClass: IonicErrorHandler},
PeopleServiceProvider,
]
})
export class AppModule {}
network.ts
import { Injectable } from '@angular/core';
import { Network } from '@ionic-native/network';
import { BehaviorSubject, Observable } from 'rxjs';
import { ToastController, Platform } from 'ionic-angular';
export enum ConnectionStatus {
Online,
Offline
}
//@Injectable({
// providedIn: 'root'
//})
export class NetworkService {
private status: BehaviorSubject<ConnectionStatus> = new BehaviorSubject(ConnectionStatus.Offline);
constructor(private network: Network, private toastController: ToastController, private plt: Platform) {
this.plt.ready().then(() => {
this.initializeNetworkEvents();
let status = this.network.type !== 'none' ? ConnectionStatus.Online : ConnectionStatus.Offline;
this.status.next(status);
});
}
public initializeNetworkEvents() {
this.network.onDisconnect().subscribe(() => {
if (this.status.getValue() === ConnectionStatus.Online) {
console.log('WE ARE OFFLINE');
this.updateNetworkStatus(ConnectionStatus.Offline);
}
});
this.network.onConnect().subscribe(() => {
if (this.status.getValue() === ConnectionStatus.Offline) {
console.log('WE ARE ONLINE');
this.updateNetworkStatus(ConnectionStatus.Online);
}
});
}
private async updateNetworkStatus(status: ConnectionStatus) {
this.status.next(status);
let connection = status == ConnectionStatus.Offline ? 'Offline' : 'Online';
console.log('test');
let toast = this.toastController.create({
message: `You are now ${connection}`,
duration: 3000,
position: 'bottom'
}).present();
};
public onNetworkChange(): Observable<ConnectionStatus> {
return this.status.asObservable();
}
public getCurrentNetworkStatus(): ConnectionStatus {
return this.status.getValue();
}
}