I'm encountering an issue with Ionic, Angular, and TypeScript, and I'm feeling a bit lost...
I'm trying to call an external function from my file but I keep getting the following error: "Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.alertCtrl.create')"
Let's first take a look at my main file:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { params } from '../../modules/params';
@Component({
selector: 'page-app',
templateUrl: 'app.html'
})
export class AppPage {
params = new params();
constructor(public navCtrl: NavController) {
this.params.popup("Hello", "test");
}
}
And now, let's examine the page where the function is located:
import { AlertController } from 'ionic-angular';
export class params {
public alertCtrl: AlertController;
constructor(){
}
popup(title, text){
let alert = this.alertCtrl.create({
title: title,
subTitle: text,
buttons: ['OK']
});
alert.present();
}
}
Where do you think I might be going wrong? Any help would be greatly appreciated. Thank you.