ionic-video-chat-support
ionic-video-chat-support copied to clipboard
Contact Modal - Not working chat() button give "name" error (Fixed)
contact-modal -> contact-modal.ts
chat() {
this.navCtrl.push(ChatPage, {chatId: this.contact.id}, {animate: true, direction: 'forward'});
this.cancel();
}
must be send chat Id but you send this.contact.id then give error and app crush
I changed your code and fixed error.
import { Component } from '@angular/core';
import { NavController, NavParams, ViewController } from 'ionic-angular';
import { ChatPage } from '../../pages';
import { CallService, ContactService, ChatService } from '../../services';
@Component({
templateUrl: 'contact-modal.html',
selector: 'modal-contact'
})
export class ContactModal {
contact = null
constructor(private viewCtrl: ViewController,private chatService: ChatService, private params: NavParams, private navCtrl: NavController, private callService: CallService, private contactService: ContactService) {
}
chat() {
// I add chatService and then send chat.id like => pages -> contacts -> contacts.ts
this.chatService.getChatByContact(this.contact.id).then((chat:any) => {
this.navCtrl.push(ChatPage, {chatId: chat.id}, {animate: true, direction: 'forward'});
})
this.cancel();
}
call() {
this.callService.triggerCall(this.contact.id);
this.cancel();
}
cancel() {
this.viewCtrl.dismiss();
}
ngOnInit() {
this.contact = this.contactService.get(this.params.get('contact').id);
}
}