Can a child view return data to the parent?

I’ve got a situation where I want a child view to be “called”, and when it is completed, to return an object to the parent view. I’m currently hacking it together by having the child view stuff the object into an angular service, and then having the parent view handle the $ionicView.beforeEnter event, to grab the object and take necessary actions. It works but it seems like there should be a better way.

there are normal angularjs events:
https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$on

you can listen to with “$on”.
$emit --> bubbles your event through the parents
$broadcast --> send your event to all children

so you could throw the event in your child-controller with
$scope.$emit('myCustomEvent', yourObject);

In the parent controller:
$scope.$on('myCustomEvent', function (event, yourObject) { ... });

I hadn’t tried this because I was under the impression that the parent view would be disconnected from the scope when the child scope was active. Per the documentation on ion-nav-view:

By default, views are cached to improve performance. When a view is navigated away from, its
element is left in the DOM, and its scope is disconnected from the $watch cycle. When
navigating to a view that is already cached, its scope is then reconnected, and the existing
element that was left in the DOM becomes the active view. This also allows for the scroll
position of previous views to be maintained.

I’ll give the emit/on a try and see what happens.

The parent scope has nothing to do with the “previous” scope!
:wink:

So you can add an abstract state --> as base controller for e.g. list and detail page --> so you can share data with both.