# Possible to load controller only once for tabs and navigation view?

**URL:** <https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671>\
**Category:** ionic-v1\
**Created:** [July 10, 2014, 1:14pm UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671 "2014-07-10T13:14:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coremaker](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@coremaker](https://forum.ionicframework.com/u/coremaker)\
**Post date:** [July 10, 2014, 1:14pm UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/1 "2014-07-10T13:14:54Z")

</div>

## I had created a pen here: [http://codepen.io/CoreMaker/pen/rGKjF](http://codepen.io/CoreMaker/pen/rGKjF)

The controller seems to load every time it enters the state. This is really troublesome if we want to simulate the native navigation view. Any workaround to this? Thanks.

And this topic below is exactly what I bump into:

> [@View and Navigation Controller](http://forum.ionicframework.com/t/view-and-navigation-controller/828/6):
>
> @adam i’m trying to keep my code DRY as possible. Here is my scenario. Tab 1 - Notifications List User click on list item and is moved to a page with more details about the notification. From there the user can click on a username to view that user’s profile Tab 2 - Events List User can click on event to view details User can click on a username in the details and view that user’s profile page Hopefully this makes more sense about the flow i’m trying to achieve. Twitter app does a simila…

After digging around a bit, I think this could be our solution to this problem.  
[http://christopherthielen.github.io/ui-router-extras/#/home](http://christopherthielen.github.io/ui-router-extras/#/home)

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [July 10, 2014, 2:20pm UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/2 "2014-07-10T14:20:42Z")

</div>

Yep but this is a wanted behave.  
Because in most cases it is necessary / wanted to execute the controller everytime you enter the stage.

If you have data to be handled not state-dependend or something like this. you can use angular services.

For the “DeepNested” function… you can use ui-routers abstract states to nest your views deep… if you navigate in substates of a abstract state the abstract state around is not loaded each time.

Or maybe I do not get it^^.

---

<div class="post-metadata">

**Author:** ![coremaker](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@coremaker](https://forum.ionicframework.com/u/coremaker)\
**Post date:** [July 10, 2014, 2:44pm UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/3 "2014-07-10T14:44:00Z")

</div>

I know that we can use angular services. But look at the codepen that I’ve shared, what if you have multiple pages that show different users’ profiles? Save all the user profiles that I have along the navigation inside the service? As of ui-router-extra, I’m still playing around with it to see if it can really solve my problem. But yeah, would really love to have this fixed. 😃

Just did some deeper readings, there’s a line stated on [ui-router-extras](http://christopherthielen.github.io/ui-router-extras/#/dsr).

> Deep State Redirect can be used with StickyStates, or on its own. If used with a Sticky State, the states will be reactivated, and the DOM will be unchanged (as opposed to the states being re-entered and controllers re-initialized)

Can any core team member take a look at this? Thanks.

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [July 10, 2014, 3:17pm UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/4 "2014-07-10T15:17:20Z")

</div>

Yeah for different profiles i would build up an array and would have a state that shows a user profile^^.

The thing, with the DOM “cache” seems to be very interesting for page transition speed.

---

<div class="post-metadata">

**Author:** ![christhielen](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@christhielen](https://forum.ionicframework.com/u/christhielen)\
**Post date:** [July 11, 2014, 1:46am UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/5 "2014-07-11T01:46:32Z")

</div>

With sticky states, the dom isn’t “cached” really. When its state is inactivated, the dom remains fully live in the browser but it is hidden by ng-show directive.

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [July 11, 2014, 6:59am UTC](https://forum.ionicframework.com/t/possible-to-load-controller-only-once-for-tabs-and-navigation-view/6671/6 "2014-07-11T06:59:17Z")

</div>

Ohh how ugly… i think about big lists with many images and so on… nice to hold everything hidden in the dom 😄
