Ionic firebase database events that open visited pages when adding/deleting

its killing me. so I have firebase database and mostly all screens is connected to firebase database. I have a page where I need to delete/add data from firebase database. the problem now is when I delete/add something it open the pages who I visited and connected to the firebase database on its own. its like a wild page jumping each pages i visited.
Does anyone experience this?? Please help!!!
Ionic Framework: ^3.6.0
Ionic App Scripts: 2.1.3
Angular Core: 4.1.2
Angular Compiler CLI: 4.1.2
Node: 6.9.4

This is probably a design error. Create a provider. Only the provider talks to Firebase. The pages then ask the provider for local copies of the information the provider got from Firebase.

I tried to move to provider but still the same. even I make a changes directly from firebase console it open the pages. really weird. any idea? :frowning:

That isn’t possible unless you’re letting it. How is your page routing connected to the database?

It is really frustrating :frowning:

I tried to remove all the code related to the firebase in PAGE 2 but after hitting savePlayer() or removePlayer() from PAGE 1 it still redirecting to PAGE 2 which is really weird. If I visited PAGE 2 10X and make a changes in PAGE 1 or even directly from firebase database console it will redirect in PAGE 2 10X as well. Please see links for the code and hopefully you might see something I don’t see

Page 1: https://paste.ofcode.org/PsTmsjtCMzXg77ctaiKJma
Page 2: https://paste.ofcode.org/XAFtKwaE3ED35wKGF3WRDf
Providers: https://paste.ofcode.org/5yQBicXxe5cFzKRcaA6xBy

Can you state, in a simple English paragraph, what you want your routing system to accomplish? There must be a better way than what you are currently doing. Plus your code has no comments.

I don’t want to redirect somewhere else after hitting these functions from PAGE 1. But every time I am hitting those functions it is redirecting to PAGE 2.

savePlayer() {
this.playersService.addPlayer(this.playerName);
this.isAddingPlayer = false;
this.playerName = null;
}

removePlayer(playerIndex) {
this.playersService.removePlayer(playerIndex);
}

another info might help.

When I run ionic “ionic serve” and went to PAGE 1 and add or remove it won’t redirect to PAGE 2 but the moment I visit PAGE 2 and went back to PAGE 1 and call savePlayer() or removePlayer() it will redirect to PAGE 2.

I hope this make sense now

You didn’t answer my question. You answered what you don’t want it to do, not what you do want t to do. The solution to your problem is probably to remove all the weird routing calls and to navigate in a debuggable, documented fashion. But I don’t even understand the purpose of your app.

I don’t think you need to know the purpose of the app.
In my code, you will see there is no routing inside of savePlayer() or removePlayer() and there is no other setting aside from I imported the config of firebase in app.module.ts. those two functions has a problem.

this is the routing function (below code) I keep using to all navigation.

gotoPage(page: string, pageType?: string) {
if (!!page) {
if (!!pageType) {
if (pageType.toLowerCase() === ‘root’) {
this.navCtrl.setRoot(page, {}, { animate: true, direction: ‘back’ });
}
} else {
this.navCtrl.push(page);
}
}
page = null;
}

basically that is all I have in my code.

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

People also don’t need to help you here.

Any suggestions? I have the same problem ):

kill the connection when you exit the page.