Reload/refresh parent activity on button click

I’ve got one list-activity which also prints a number for all instances in the storage (SQLite-database). On the child activities of this list, the users are able to “check-in”, adding another instance to the storage. The problem now is that when the user returns to the previous activity, the number on the parent activity is not incremented.

Therefore, is it possible to refresh the parent activity when a button on a child activity is pressed?

To illustrate, here are two screenshots. Left is the parent, right is the child. I would like the whole activity on left to refresh when the button “sjekk inn” on the right are clicked. This will both increment the number on top and add a green checkmark to the card.


I’m confused by your use of the term “activity”, so I’m going to a assume it means “page”. Create a service provider that contains a Subject that exposes what that number is and somehow provides logic to know when the checkmark should be displayed. In the “parent” page, inject the provider, subscribe to these, and update page properties appropriately. In the “child” page, also inject the provider and call next() to trigger updates.

On “dirty” way: Send an Ionic Event when somebody does something, listen for it on the parent and reload the number (or add 1 manually if you are really lazy).

Sorry! I’ve been doing some Android-development from before, and have therefore learned to use the term “activity”. But you’re totally right in your assumption, I’m using it as a name for page.

As for your answer, thank you very much :slight_smile:

1 Like

Thanks! Even though this is the “dirty” way, I ended up using this method. Small projects requires easy solutions :wink:

1 Like

I think following good habits is important, regardless of the size of the project. Why I don’t like Events.

1 Like