Hi all! I have a crazy issue. I instantiated a custom provider in an Ionic Page, but it seems to be undefined.
This is my runtime error:
Error: Can't resolve all parameters for VideoPage3: ([object Object], [object Object], ?).
at syntaxError (http://localhost:8100/build/vendor.js:92309:34)
at CompileMetadataResolver._getDependenciesMetadata (http://localhost:8100/build/vendor.js:107390:35)
at CompileMetadataResolver._getTypeMetadata (http://localhost:8100/build/vendor.js:107225:26)
at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (http://localhost:8100/build/vendor.js:106733:24)
at CompileMetadataResolver._getEntryComponentMetadata (http://localhost:8100/build/vendor.js:107538:45)
at http://localhost:8100/build/vendor.js:107008:72
at Array.map (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/vendor.js:107008:18)
at JitCompiler._loadModules (http://localhost:8100/build/vendor.js:125385:87)
at JitCompiler._compileModuleAndComponents (http://localhost:8100/build/vendor.js:125346:36)
and this is my ionic info
:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
ios-sim : 3.1.1
Node : v8.9.3
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /usr/local/share/android-sdk
Misc:
backend : legacy
The crazy thing is that I’ve imported this provider in the same way on two pages, but no error is occured in the other one. The two Ionic Pages are below:
// THIS IS THE "BAD" PAGE
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ManagerService } from '../../providers/manager-service/manager-service';
@IonicPage()
@Component({
selector: 'page-3-video',
templateUrl: '3-video.html'
})
export class VideoPage3 {
data: any = {};
video : string = ''; // Default
constructor(public navCtrl: NavController, public navParams: NavParams, private _manager: ManagerService) {
console.log('Current Step',this._manager.getStep());
this.data = this.navParams.data;
if(this.data) {
this.video = this._manager.getMediaPath(this.data.data['media-video']);
console.log('Video Path', this.video);
}
}
ionViewDidLoad() {
console.log('ionViewDidLoad MediaVideoPage');
}
goBack(event) {
console.log(event);
this.navCtrl.pop();
}
}
// THIS IS THE "GOOD" PAGE
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ManagerService } from './../../providers/manager-service/manager-service';
@IonicPage()
@Component({
selector: 'page-2C-adventure-chioces',
templateUrl: '2C-adventure-chioces.html',
})
export class AdventureChiocesPage2C {
adventures: any[] = [];
constructor(public navCtrl: NavController, public navParams: NavParams, private _manager: ManagerService) {
this.adventures = this._manager.getPermittedAdventureHeaders();
}
ionViewDidLoad() {
console.log('ionViewDidLoad AdventureChiocesPage');
console.log("ADVENTURES:", this.adventures)
}
goBack(event) {
console.log(event);
this.navCtrl.pop();
}
}
I tried with the creation of provider in the constructor page, but the provider must be global. In other discussions, someone talks about circular dependencies, but if it is so, the problem should be in the second page too, isn’t it?
I hope someone can help me!!!
Thanks in advance!!