Sure. From example when I call the selectClientModal($event) it throws the error at line 181(see bold section) in edit-modal.ts. If you notice the .ts file I have commented out all the console.log lines. It works for the time being but that obviously not the solution. Funny thing is that I have used console.log everywhere but it only throws the error from this page onwards.
edit-job.html file(this is only part of the code):
<ion-item>
<ion-label stacked>Client Name*</ion-label>
<ion-input type="search" (ionFocus)=selectClientModal($event) [(ngModel)]="clientName" name="clientName" autocomplete="on" required></ion-input>
</ion-item>
edit-job.ts file(it throws an error everywhere at the console.log and also in the modal when the modal is opened)
import { Component } from ‘@angular/core’;
import { IonicPage, AlertController, NavController, NavParams, ViewController, ModalController, LoadingController } from ‘ionic-angular’;
import { Storage } from ‘@ionic/storage’;
import moment from ‘moment’;
import ‘moment-timezone’;
import { ApiserviceProvider } from ‘…/…/providers/apiservice/apiservice’;
@IonicPage()
@Component({
selector: ‘page-edit-job’,
templateUrl: ‘edit-job.html’,
})
export class EditJobPage {
job: any;
user_id: any;
driver: any;
driverID: any;
suburb1: any = [{_id:’’}];
suburb2: any;
suburb2ID: any;
pickUpSuburb: any;
dropSuburb: any;
rateLevel: any;
storyDesc: any;
rate: any;
client: any = [{_id:’’}];
items: any;
loading: any;
jobDate: any;
clientName: any;
PickUp: any;
Drop: any;
assignedTo: any;
RateLevel: any;
Notes: any;
story: boolean = false;
story_desc: any;
myDate: any;
constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController, public modalCtrl: ModalController, public apiservice: ApiserviceProvider, public loadingCtrl: LoadingController, public alertCtrl: AlertController, public storage: Storage) {
this.storage.get('user_id').then((data) => {
this.user_id = data;
console.log("User Id: "+this.user_id)
this.job = navParams.get('job');
console.log = this.job;
this.jobDate = this.job.jobDate;
this.clientName = this.job.client.client;
this.client._id = this.job.client._id;
this.pickUpSuburb = this.job.pickUpSuburb.suburb;
this.suburb1._id = this.job.pickUpSuburb._id;
if(this.dropSuburb){
this.dropSuburb = this.job.dropSuburb.suburb;
}
if(this.rateLevel){
this.rateLevel = this.job.rateLevel;
}
if(this.story){
this.story = this.job.story;
}
if(this.storyDesc){
this.storyDesc = this.job.storyDesc;
}
if(this.assignedTo){
this.assignedTo = this.job.assignedTo.name;
}
});
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad AddNewJobPage’);
this.rate =[
{level:'6TT'},
{level:'8TT'},
{level:'12TT'},
{level:'8TC'},
{level:'12TC'},
{level:'Semi Trailer'},
];
}
save(form){
/*
let alert = this.alertCtrl.create({
title: ‘In Progress’,
subTitle: ‘This feature is under development…’,
buttons:
[
{
text: ‘Ok’,
handler: () => {
}
}
]
});
alert.present();
*/
this.presentLoading();
/*
console.log("Job Date: "+moment(form.value.jobDate).tz('Australia/Sydney').format('YYYY-MM-DDT00:00:00.000'));
console.log("Job Date: "+form.value.jobDate);
console.log(form.value.clientName);
console.log(form.value.pickUpSuburb);
console.log(form.value.dropSuburb);
console.log(form.value.rateLevel);
console.log(form.value.story);
console.log(form.value.storyDesc);
console.log(form.value.assignedTo);
*/
let newDate = moment(form.value.jobDate).tz('Australia/Sydney').format('YYYY-MM-DDT00:00:00.000');
// console.log("New Job Date: "+newDate);
// ----------- Object to store visitor info -----------
let info = {
job_id : this.job._id,
jobDate: moment(form.value.jobDate).tz('Australia/Sydney').format('YYYY-MM-DDT00:00:00.000'),
client: this.client._id,
pickUpSuburb: this.suburb1._id,
dropSuburb: this.suburb2ID,
weight: form.value.weight,
length: form.value.lenght,
rateLevel: form.value.rateLevel,
story: form.value.story,
storyDesc: form.value.storyDesc,
assignedTo: this.driverID,
addedBy: this.user_id
};
// console.log("Job Info: "+info);
// -------------------- Insert Into DB ----------------------
this.apiservice.editJob(info).then((data) => {
// console.log(data);
this.dismissLoading();
if(data == 'Success'){
// console.log("Succcess. Presenting alert...");
this.presentAlert();
}
else
{
// console.log("Error. Please Try Again.");
this.presentErrorAlert();
}
});
}
**selectClientModal(ev: any){**
// console.log(“Modal opened”);
let modal = this.modalCtrl.create(‘SearchClientPage’, { userId: 8675309 });
// When the modal is dismissed the selected info is returned here.
modal.onDidDismiss(data => {
// console.log("Selected Client is: "+JSON.stringify(data));
this.client = data;
this.clientName = data.client;
// console.log("Selected Client Id: "+this.client._id);
});
modal.present();
}
selectDriverModal(ev: any){
// console.log(“Driver Modal opened”);
const modal2 = this.modalCtrl.create(‘SearchDriverPage’, { userId: 8675309 });
// When the modal is dismissed the selected info is returned here.
modal2.onDidDismiss(data => {
// console.log("Selected Driver is: "+JSON.stringify(data));
this.driver = data;
this.assignedTo = this.driver.name;
// console.log("Driver Name: "+this.assignedTo);
this.driverID = this.driver._id;
// console.log("Selected Driver Id: "+this.driverID);
});
modal2.present();
}
pickUpSuburbModal(ev: any){
// console.log(“Modal opened”);
const modal3 = this.modalCtrl.create(‘SearchSuburbPage’, { userId: 8675309 });
// When the modal is dismissed the selected info is returned here.
modal3.onDidDismiss(data => {
// console.log("pickUp Suburb is: "+JSON.stringify(data));
this.suburb1 = data;
this.pickUpSuburb = this.suburb1.suburb;
// console.log("pickUp Suburb Id: "+this.suburb1._id);
});
modal3.present();
}
dropSuburbModal(ev: any){
// console.log(“Modal opened”);
const modal4 = this.modalCtrl.create(‘SearchSuburbPage’, { userId: 8675309 });
// When the modal is dismissed the selected info is returned here.
modal4.onDidDismiss(data => {
// console.log("drop Suburb is: "+JSON.stringify(data));
this.suburb2 = data;
this.suburb2ID = data._id;
this.dropSuburb = data.suburb;
// console.log("drop Suburb Id: "+this.suburb2ID);
});
modal4.present();
}
cancel(){
this.viewCtrl.dismiss();
}
presentLoading(){
this.loading = this.loadingCtrl.create({
content: 'Please wait...'
});
this.loading.present();
}
dismissLoading(){
this.loading.dismiss();
}
presentAlert(){
let alert = this.alertCtrl.create({
title: ‘Success’,
subTitle: ‘Changes Saved Successfully!’,
buttons:
[
{
text: ‘Ok’,
handler: () => {
// console.log(‘Ok clicked’);
this.viewCtrl.dismiss();
}
}
]
});
alert.present();
}
presentErrorAlert(){
let alert = this.alertCtrl.create({
title: ‘Error’,
subTitle: ‘Could not be save. Please Try Again.!’,
buttons:
[
{
text: ‘Ok’,
handler: () => {
// console.log(‘Ok clicked’);
}
}
]
});
alert.present();
}
}