Closing the Ionic Swipeable List on View Leave

I am trying to figure out how to detect leaving a view, so I can run a little cleanup on the $ scope. I found $ ionicView (which I prefer to use the start and end of the UI-Routers transition) and tried it in my child controller:

// When placed in child view doesn't fire, but works when dropped in parent
$scope.$on("$ionicView.leave", function (event, data) {
    $ionicListDelegate.closeOptionButtons();
});

      

But nothing happens. So after some reading I found that I only have fire left in parent space, so I moved it to parent and injected $ ionicListDelegate and it works, buuut (and now my question), I really feel like there must be a better way to do this is. Since my views are cached using $ destroy this won't work. Does anyone know in another way that I can do this? Or has this almost global list close event called on the parent not such a bad approach since lists are used a lot in my application?

+3


source to share





All Articles