很抱歉,如果这似乎与其他问题重复,因为它们无法解决我的问题。有人可以帮我弄这个吗?我已经尝试逐个删除参数,但仍然没有好处。
Can't resolve all parameters for MyApp: (?, ?, ?, ?, ?, ?).
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Subscription } from 'rxjs';
import { GlobalService } from '../services/global-service';
import { TabsPage } from '../pages/tabs/tabs';
import { File } from '@ionic-native/file';
import { Insomnia } from '@ionic-native/insomnia';
@Component({
templateUrl: 'app.html'
})
export class MyApp{
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private global : GlobalService,
private file: File, private insomnia: Insomnia){}
}
app.module.ts
import { MyApp } from './app.component';
import { Platform } from 'ionic-angular';
import { GlobalService } from '../services/global-service';
import { UserService } from '../services/user-service';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileTransfer } from '@ionic-native/file-transfer';
import { Insomnia } from '@ionic-native/insomnia';
import { Network } from '@ionic-native/network';
import { MusicControls } from '@ionic-native/music-controls';
@NgModule({
declarations: [
MyApp,
...
],
imports: [
...
],
bootstrap: [...],
entryComponents: [
MyApp
],
providers: [
Platform,
StatusBar,
SplashScreen,
Insomnia,
File,
FileTransfer,
Network,
MusicControls,
{provide: ErrorHandler, useClass: IonicErrorHandler},
GlobalService,
UserService,
{ provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig }
]
})
export class AppModule {}
服务/全局service.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Subject } from 'rxjs/Subject';
import { File } from '@ionic-native/file';
import { Platform } from 'ionic-angular';
import * as SoundFont from 'soundfont-player';
import * as Firebase from 'firebase';
import 'firebase/firestore';
import 'rxjs/Rx';
@Injectable()
export class GlobalService {..}
似乎无法找到我的错误的根本原因。我正在使用Ionic 3.9.2,Angular Core 5.2.9,Node 6.10.2。我的node_modules或我的一些配置可能有问题吗?
答案 0 :(得分:3)
您未提供Platform
作为提供商。
import { MyApp } from './app.component';
import { GlobalService } from '../services/global-service';
import { UserService } from '../services/user-service';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileTransfer } from '@ionic-native/file-transfer';
import { Insomnia } from '@ionic-native/insomnia';
import { Network } from '@ionic-native/network';
import { MusicControls } from '@ionic-native/music-controls';
@NgModule({
declarations: [
MyApp,
...
],
imports: [
...
],
bootstrap: [...],
entryComponents: [
MyApp
],
providers: [
Platform,
StatusBar,
SplashScreen,
Insomnia,
File,
FileTransfer,
Network,
MusicControls,
{provide: ErrorHandler, useClass: IonicErrorHandler},
GlobalService,
UserService,
{ provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig }
]
})
export class AppModule {}
简单地说Can't resolve all parameters for MyApp: (?, ?, ?, ?, ?, ?).
意味着你的应用程序的构造函数所期望的所有参数都没有得到满足。
修改
也许您在App
组件上缺少app-root选择器。
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Subscription } from 'rxjs';
import { GlobalService } from '../services/global-service';
import { TabsPage } from '../pages/tabs/tabs';
import { File } from '@ionic-native/file';
import { Insomnia } from '@ionic-native/insomnia';
@Component({
selector: 'app-root',
templateUrl: 'app.html'
})
export class MyApp{
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private global : GlobalService,
private file: File, private insomnia: Insomnia){}
}
答案 1 :(得分:0)
如果这样做,请撤消更改或确保构建文件的顺序为polyfills.js, vendor.js and main.js
,因为我确实尝试重现此问题。