角度2,离子。无法解析HomePage的所有参数

时间:2017-05-02 16:53:43

标签: angular ionic-framework ionic-native

以下我遗漏了什么?我正在尝试使用Cordova-camera-plugins和ion native,使用Ionic 2,但是在离子发送后我收到以下运行时错误:“无法解析HomePage的所有参数:([object Object],[object Object], [object Object],[object Object],?)。“

Home.ts

import { Component, Injectable } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ToastController } from 'ionic-angular';
// import { File } from '@ionic-native/file';
import { Diagnostic } from '@ionic-native/diagnostic';
import { CameraPreview, CameraPreviewOptions, CameraPreviewDimensions} from '@ionic-native/camera-preview';
declare var cordova: any;

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',

})

@Injectable()
export class HomePage {

  constructor(
    private navCtrl: NavController,
    private toastCtrl: ToastController,
    // public file:File,
    public diagnostic:Diagnostic,
    public cameraPreview: CameraPreview,
    public previewRect: CameraPreviewOptions
  ) {  this.checkPermissions(); }

app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';


import { HomePage } from '../pages/home/home';
import { Diagnostic } from '@ionic-native/diagnostic';


import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
  declarations: [
    MyApp,
    HomePage,
  ],
  imports: [
     BrowserModule,
     IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
    entryComponents: [
     MyApp,
     HomePage,
     Diagnostic
  ],
  providers: [
    StatusBar,
    SplashScreen,
    Diagnostic,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    {provide: Diagnostic, useClass: Diagnostic}
   ]
})
export class AppModule {}

1 个答案:

答案 0 :(得分:3)

我曾经得到同样的错误,现在已经修复了。 “无法解析HomePage的所有参数:([object Object],[object Object],[object Object],[object Object],?)。”。

“?”可能意味着无法识别或某事,所以尝试删除构造函数中的一些参数,并将它们声明为普通数据成员(在构造函数上方)。例如,“public previewRect:CameraPreviewOptions”。