can't resolve all parameters for [object OBJECT], after ionic serve

J.Rem picture J.Rem · May 2, 2017 · Viewed 19.2k times · Source

not sure what I'm doing wrong, but when trying to use ionic and Cordova plugins I receive the following error after ionic serve: "can't resolve all parameters for [object OBJECT],[object OBJECT],[object OBJECT],[object OBJECT],[object OBJECT],?"

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',
  providers: [CameraPreview, Diagnostic]
})
export class HomePage {

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

Answer

Iris_geek picture Iris_geek · Jun 29, 2017

I got the same issue somewhere, so I removed the last parameter of constructor and given it before constructor. In your case like this,

export class HomePage {

 public previewRect: CameraPreviewOptions;

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

I don't know if this is the right solution but resolved my issue.