$scope problem between views


#1

Hi,
I’ve been banging my head trying to get something (which I think looks straightforward) working.

I’m new to ionic and sort of new to angular.

Case: I have page1, I want to click a link, select a value from page2, for it to go back to page1 and be reflected. I have both routes tied to the same controller. The flow works, but the data is not reflected in page1.

Here’s a test case: http://plnkr.co/edit/pzYKq79bVTyaSxUdefuE?p=preview

I have a feeling it’s something to do with $scope and ion-content (and child $scopes being created in ion-content), and if that’s the case, I don’t get how I’m supposed to do this type of flow?

Help much appreciated.


#2

You would typically create a service to hold data shared between different views, each view would have its own controller that depends on the shared service.

I’ve never tried declaring the same controller for two views, I suspect it may actually result in separate instances of the same controller but I’m not entirely sure.


#3

That worked great and is a lot better approach than I was trying to do.

Thanks for your help!