Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

My app has two states home.summary(parent state) and home.summary.detail(child state) and I want to show on same state with different url.

Is there a way to achieve this?From state of home.summary start with URL:/home/summary and then to /home/summary/detail/:id without changing state.

  • AngularJS version:1.2.14
  • Angular-ui-router version:0.2.7

routes.js looks like below mentioned:

.state('home', {
              abstract: true,            
              url: '/home',
              templateUrl: 'scripts/home.html'
       })
.state('home.summary', {
    url: '/summary?userId',                 
    views: {               
           'summary': 
              {
                        templateUrl: "scripts/home/summary.html"
              }
           }
    })
.state('home.summary.detail', {
    url: '/detail/:id',                 
    views: {               
           'detail': 
              {
                        templateUrl: "scripts/home/detail.html"
              }
           }
    })

My app has Angular-ui-bootstrap tabs and when switching between tabs need to change the url.

Summary Tab which is Static tab and has a state called home.summary and url is /home/summary.

Detail tab which is dynamic tab and has a state which is child of summary and url is /home/summary/detail/:id

Switching between tabs changes states using ui-sref and this causes memory leaks if I remove ui-sref I don't see any leaks.

I have noticed that $state.go re-initializes the controllers and scope variable in those controllers get updated and causes memory leaks.Is there a way to stop re-initializing the controllers on state change but change url??

or

have one state going to different url's??

share|improve this question
    
You can define 2 stated with 2 different URLs, and use the same template and controller for both, bad practice yes, but what you're looking to do is fundamentally bad practice. – user189756 Apr 29 '14 at 4:21
    
I was hitting with memory leaks when changing states between parent to child and child to parent,so trying to use one state from where i can point to different url's.My app has summary tab(static) and detail tabs(dynamic) and summary has state and need to go to detail tab from summary and detail has a state which is child state. – EnugulaS Apr 29 '14 at 4:30
    
Personally I would use "search" parameters to control what tab is shown as they can be optional. I made a plunkr way back demonstrating how tabs could be controlled: plnkr.co/edit/cqZfgfv69fzsfnrxj9Gz?p=preview (Using dotjem.routing instead though) – Jens Apr 29 '14 at 8:28
    
is this example in plunk shows different urls on browser when switching tabs from same state? – EnugulaS Apr 29 '14 at 23:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.