Reputation: 99
I am using Aurelia for this first time. While doing the contact manager tutorial, I faced a problem with RouteConfig.navModal.title
. Everytime I try to trigger that line, I am getting
Uncaught (in promise) TypeError: this.routeConfig.navModal is undefined
My Code looks something like this:
This is my .ts file:
async save() {
await this.api.saveContact(this.selectedContact)
.then((contact: IContact) => {
this.selectedContact = {
id: contact.id,
firstName: contact.firstName,
lastName: contact.lastName,
email: contact.email,
phoneNumber: contact.phoneNumber
}
});
this.routeConfig.navModal.title = this.selectedContact.firstName;
this.originalContact = JSON.parse(JSON.stringify(this.selectedContact));
}
This my .html file, exactly where the button is triggered:
<div>
<button
class="btn btn-success float-right"
click.delegate="save()"
disabled.bind="!canSave"
>
Save
</button>
</div>
Also here is my api.saveContact method:
saveContact(contact: IContact){
this.isRequesting = true;
return new Promise<IContact>(resolve => {
setTimeout(() => {
let instance = JSON.parse(JSON.stringify(contact));
let found = contacts.filter(x => x.id == contact.id)[0];
if(found){
let index = contacts.indexOf(found);
contacts[index] = instance;
}else{
instance.id = getId();
contacts.push(instance);
}
this.isRequesting = false;
resolve(instance);
}, latency);
});
}
The whole issue is in line:
this.routeConfig.navModal.title = this.selectedContact.firstName;
What am I doing wrong?
PS. I also tried this.routeConfig.navModal.setTitle(this.selectedContact.firstName);
that didnt work too.
Upvotes: 0
Views: 32