Ionic Modal: Same modal with New data, not preserving previous state


#1

I’m building an ionic app in which I want to achieve something very simple, but can’t get my head around the solution.
What I have is a user profile view which has a link to the user’s followers/following list. Now when click on that user I want to open it in a modal and then to that users followers list. Any user could go on checking different profiles this way.

What I have is an array of users which has a property current profile (yes/no) which indicates what data the modal should show. But when I hit back I want all the data of previous profiles visited to be there.Basically I want to create a new instance of Ionic modal with that new user profile data. What’s happening in my case is I’m doing a $ionicModal.fromTemplateUrl and then when I hit a new user the previous modal which is basically the same modal also has that latest users data instead of persisting the previous state. I have tried using directives.
I also was thinking of injecting dynamic html string with an $ionicModal.fromTemplate which takes in html string as parameter instead of url, strangely I get an error saying this method is undefined. Whereas I can see it in the documentation.