2

Christoper,

I was wondering if the use case of having dynamically generated tabs, think of a list of clients, would work with your solution for tabs in ui-router extras? The issue is that your example uses named ui-views which would not work in my situation as they are generated at runtime and the routes that you added are at config time.

Thanks in advance, Luisz

1 Answers1

0

You can generate states dynamically just using $stateProvider in your controller and the ui-view name in the view binding the name

<div ui-view="myView{{variable}}"></div>

There was an issue using interpolated views, but is solved since 0.2.12 (Upload to latest 0.2.13 in case it doesn't work) and here is an example but without ui-router-extras. Let us know if it works fine or update a plnkr.

  • Matho, thanks for your reply. The issue is that you still have two hardcoded states step1 and step2 in the $stateProvider. I need to generate a dynamic state that is linked to a dynamic tab. – Luisz Bobirca Apr 06 '15 at 15:38
  • But you can add new states in any moment, the only thing you have to do is create a service which will call the $stateProvider, you can check several examples [here](http://stackoverflow.com/questions/25866387/angular-ui-router-programmatically-add-states) – Matias Fernandez Martinez Apr 07 '15 at 04:02
  • Yea, I looked into that yesterday, but it is not a good approach to know what states you need to load. The whole point is so that you can set up a pattern and when you call state.go or you copy the URL into a browser it will follow the route. I don't know what data the user will select ahead of time. What I really need is a ui-view for each route that is taken and a way in the $stateProvider to link the view name to a variable like the way that ui-router has for the url: '/step/{number}'. – Luisz Bobirca Apr 07 '15 at 16:32
  • I think is more a design issue, You can use took part of the url as stateParams for instance _url: '/myParent/myVuew/{selectedTabId:[a-zA-Z0-9.]+}',_ and then in your controller with $stateParams you can extract the value of that selectedTabId for instance and render something or init another nested view – Matias Fernandez Martinez Apr 07 '15 at 16:54
  • 1
    Matho, my goal is to keep the DOM around in a seperate ui-view. Imagine a list of clients on the left and the detail for each on the right. You want to go back and forth between clients and not lose the state of the clients you are currently editing. This is the use case. We want to use ui-router for this so we can hydrate the client if someone opens it with a URL or in code by calling $state.go. – Luisz Bobirca Apr 07 '15 at 23:17