Only instances of Provider and Type are allowed, got: [?undefined?]
It is something to do with openUser and openPage
here is the provider
import { Injectable, } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import {ThemeableBrowser } from 'ionic-native';
import { ModalController, NavController } from 'ionic-angular';
import { OpenUserPage } from '../pages/open-user/open-user';
import { OpenPagePage } from '../pages/open-page/open-page';
import { OpenMenuPage } from '../pages/open-menu/open-menu';
import jQuery from "jquery";
import { HomePage } from '../pages/home/home';
/*
Generated class for the CustomProvider provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class CustomProvider {
constructor(public http: Http, public modalCtrl: ModalController, public navCtrl: NavController) {
//console.log('Hello CustomProvider Provider');
}
launch(url) {
let options = {
statusbar: {
color: '#ffffffff'
},
toolbar: {
height: 44,
color: '#f0f0f0ff'
},
title: {
color: '#003264ff',
showPageTitle: true
},
backButton: {
wwwImage: 'assets/img/back-small.png',
wwwimagePressed: 'assets/img/back-small.png',
align: 'left',
event: 'backPressed'
},
forwardButton: {
image: 'forward',
imagePressed: 'forward_pressed',
align: 'left',
event: 'forwardPressed'
},
closeButton: {
wwwImage: 'assets/img/back-small.png',
wwwimagePressed: 'assets/img/back-small.png',
align: 'left',
event: 'closePressed'
},
customButtons: [
{
image: 'share',
imagePressed: 'share_pressed',
align: 'right',
event: 'sharePressed'
}
],
menu: {
image: 'menu',
imagePressed: 'menu_pressed',
title: 'Test',
cancel: 'Cancel',
align: 'right',
items: [
{
event: 'helloPressed',
label: 'Hello World!'
},
{
event: 'testPressed',
label: 'Test!'
}
]
},
backButtonCanClose: true
};
let browser = new ThemeableBrowser(url, '_blank', options);
browser.show();
}
openUser(userID, isModal=false){
//console.log(menuItem);
var goto = false;
var navOptions = {
animation: 'ios-transition',
direction: 'forward',
animate: true
};
if (isModal) {
var modal = this.modalCtrl.create(OpenUserPage, {
userID: userID
});
modal.present();
} else {
this.navCtrl.push(OpenUserPage, {
userID: userID
}, navOptions);
}
}
openPage(pageID, isModal=false){
//console.log(menuItem);
var goto = false;
var navOptions = {
animation: 'ios-transition',
direction: 'forward',
animate: true
};
if (isModal) {
var modal = this.modalCtrl.create(OpenPagePage, {
pageID: pageID
});
modal.present();
} else {
this.navCtrl.push(OpenPagePage, {
pageID: pageID
}, navOptions);
}
}
openMenuItem(menuItem, isModal=false){
//console.log(menuItem);
var navOptions = {
animation: 'ios-transition',
direction: 'forward',
animate: true
};
if (isModal) {
var modal = this.modalCtrl.create(OpenMenuPage, {
menuItem: menuItem
});
modal.present();
} else {
this.navCtrl.push(OpenMenuPage, {
menuItem: menuItem
}, navOptions);
}
}
resetHeaderHeight(){
jQuery(function () {
var headerHeight = jQuery("#header").height();
setTimeout(function () {
jQuery(".scroll-content").css('margin-top', headerHeight + 'px');
}, 200);
});
}
goBack(direction, isModal) {
/// will need a direction here.
var direction = direction;
if(direction !== 'forward'){
direction = 'back';
}
var navOptions = {
animation: 'ios-transition',
direction: direction,
animate: true,
};
if(isModal == true){
this.navCtrl.pop();
}else{
this.navCtrl.pop(navOptions);
}
}
goToHome() {
//push another page onto the history stack
//causing the nav controller to animate the new page in
var navOptions = {
animation: 'ios-transition',
direction: 'forward',
animate: true,
};
this.navCtrl.push(HomePage, null, navOptions);
//this.nav.push(Page1,{},{animate: true, direction: 'back'});
}
}
indent preformatted text by 4 spaces
here is the class
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { HomePage } from '../../pages/home/home';
import { Platform } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
//import {NativePageTransitions, TransitionOptions} from 'ionic-native';
import { ModalController } from 'ionic-angular';
//import jQuery from "jquery";
import {CustomProvider} from '../../providers/custom-provider';
/*
Generated class for the OpenMenu page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-open-user',
templateUrl: 'open-user.html',
providers: [CustomProvider]
})
export class OpenUserPage {
public userID:any;
public user:any;
public menuItem:any;
public isModal:any;
public navBackDirection:any;
constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController, platform: Platform, public http: Http) {
this.userID = navParams.get("userID");
this.user = false;
this.isModal = navParams.get("isModal");
this.navBackDirection = navParams.get("navBackDirection");
// get children
var url = 'https://testing.insightmobilecms.co.uk/device/api/user/'+this.userID+'?userAPIKey=a7472d89-e032-3ff6-5379-db93cdfaed6f&eventAPIKey=00D1B8C3-49E4-0A7E-E57C-6640F0F6C48F&eventID=1&ajax=true';
//alert(url);
this.http.get(url).map(res => res.json())
.subscribe(data => {
// alert(JSON.stringify(data));
this.user = data['user'];
console.log('success');
//alert(url);
}, err => {
console.log('error http ' + err);
});
// console.log( 'menuItemChildren' + this.menuItemChildren );
}
ionViewDidLoad() {
/* console.log('ionViewDidLoad OpenMUserPage');
jQuery(function () {
var headerHeight = jQuery("#header").height();
setTimeout(function () {
jQuery(".scroll-content").css('margin-top', headerHeight + 'px');
}, 100);
});*/
// this.CustomProvider.resetHeaderHeight();
}
goBack() {
/// will need a direction here.
var direction = this.navBackDirection;
if(direction !== 'forward'){
direction = 'back';
}
var navOptions = {
animation: 'ios-transition',
direction: direction,
animate: true,
};
if(this.isModal == true){
this.navCtrl.pop();
}else{
this.navCtrl.pop(navOptions);
}
}
goToHome() {
//push another page onto the history stack
//causing the nav controller to animate the new page in
var navOptions = {
animation: 'ios-transition',
direction: 'backward',
animate: true,
};
this.navCtrl.push(HomePage, null, navOptions);
//this.nav.push(Page1,{},{animate: true, direction: 'back'});
}
}