I’m developing an app using ui-router resolve and Beta-14.
When i navigate through my app states, each state resolve the needed resource.
In Navigating the Changes in Beta-14 i read that “controllers persist throughout the app’s life” and event $ionicView.loaded is fired only when a view being added to the DOM.
(Cached views are awesome )
But…I create this pen to show the (incorrect ??) behavior.
When navigate between Home and Facts, views are cached but the event $ionicView.loaded and resolve are always fired.
Is there a method to avoid firing of resolve after first time???
If i have a list of products and switch between list-detail-list-detail-list-detail i don’t want to resolve “list” state each time.
I had to introduce some kind of identifier, since most of my resolves use $stateParams, so ref.uri uniquely identifies this view instance. I first wanted to use delegate-handle but according to https://github.com/driftyco/ionic/issues/1865, the delegate-handle attribute doesn’t support interpolation
This way, searching fo a cached view instance becomes
$ionicNavViewDelegate._instances.forEach(function(instance) {
var viewElements = instance.getViewElements();
for (var i = 0, length = viewElements.length; i !== length; ++i) {
var viewElement = viewElements.eq(i);
if (viewElement.attr('delegate-id') === $stateParams.uri) {
leave = true;
}
}
});