State resolving and cached views in Beta-14


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 :smiley: )

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.

Thanks a lot and sorry for my english!

Cached Views and UI-Router Resolves

+1. did you find a solution?


@adw unfortunately no…


AFAICS, this is still the case with rc-2. I’d really like cached views to behave sanely with respect to resolve


Anybody filed a bug report for this?


@tkem No… I never thought it…


Any solution yet ?, have the same problem


Have the same problem. Here is my workaround

       .state('app.customers', {
            url: "/customers",
            views: {
                'menuContent': {
                    templateUrl: "templates/index.html",
                    controller: 'CustomerIndexCtrl'
            resolve: {

                customers: function ($customers, $ionicNavViewDelegate) {
                    var leave = false;
                    $ionicNavViewDelegate._instances.forEach(function (instance) {
                        var viewElements = instance.getViewElements();
                        for (var x = 0, l = viewElements.length; x < l; x++) {
                            var viewElement = viewElements.eq(x);
                            var eleIdentifier ='$eleId');
                            if ('app.customers' == eleIdentifier) {
                                leave = true;

                    if (!leave) {
                        return $;



Thanks for sharing! I will look into this and see how this works with $stateParams.


@chrfritsch, i hereby officially announce you my “personal hero of the week” :wink:

I took a little different approach, introducing a custom delegate-id attribute to my views:

<ion-view delegate-id="{{ref.uri}}" view-title="{{ || ref.uri}}">

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, the delegate-handle attribute doesn’t support interpolation :frowning:

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;

So, once again, thanks for sharing this!


@chrfritsch Thanks for sharing!

You ar my “personal hero of the week” too :smiley: :smiley: :smiley: