@Sweg wrote:
In my Ionic Angular app, I am creating a LoadingController in the below method:
Conversation-detail.page.ts:
onSendMessage() { this.loadingCtrl.create({ message: 'Sending Message...' }).then(loadingEl => { loadingEl.present(); this.conversationsService.addMessageToConversation(this.conversation.id, this.form.value.message); }) }
Once the LoadingController is presented, I want to execute
this.conversationsService.addMessageToConversation(...)
Then once that method is executed successfully, I want to execute
loadingEl.dismiss()
, but I don’t know where to call this. It should only be dismissed ifaddMessageToConversation(...)
is executed.Can someone please tell me how I can resolve this?
Also, here is some of my other code (can provide more if required:
Conversations.service.ts:
addMessageToConversation(conversationId: string, message: string) { this.getConversationToAddMessage(conversationId).messages.push(this.createMessage(message)); } getConversationToAddMessage(id: string) { return this._conversations.getValue().find(conversation => conversation.id === id); }
Posts: 1
Participants: 1