When using loader or toast controller from ionic from inside a component, they are not displaying.
But when used in usual Ionic Page it is working fine .
Snippet of my component :
import { ToastService } from './../../../services/modalViews/toastService';
import { Component, Input } from '@angular/core';
import { IonicPage, NavController, NavParams, Events, LoadingController } from 'ionic-angular';
@Component({
selector: 'message-detail',
templateUrl: 'messageDetail.component.html',
})
export class MessageDetail {
messageToSend : String = "";
constructor(public navCtrl: NavController, public navParams: NavParams, event : Events, public toast : ToastService, public loading : LoadingController ) {
}
sendMessage() : void {
console.log("message to send",this.messageToSend);
console.log("isEmail", this.isEmail);
if (this.messageToSend.length > 0 ){
let loader = this.loading.create({
content: 'Loading'
});
this.messageService.sendMessage(this.isEmail, this.buildMessageBody(this.messageToSend, this.isEmail)).subscribe(res =>{
console.log("res messages sent", res);
loader.dismiss();
this.myScrollToBottom();
}, err =>{
console.log(err);
loader.dismiss();
this.toast.getErrorToast(err);
})
}
}
}