Skip to content

Dynamic state url #1323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vko-online opened this issue Sep 1, 2014 · 8 comments
Closed

Dynamic state url #1323

vko-online opened this issue Sep 1, 2014 · 8 comments

Comments

@vko-online
Copy link

App structure

$stateProvider.
    state('azured', {
        url: "/azured/",
    }).
    state('azured.ref', {
        url: "/ref",
    }).
    state('azured.ref.table', {
        url: "/table/:tableId",
    }).
    state('azured.ref.table.list', {
        url: "/list/:listId",
    }).
    state('azured.ref.table.list.item', {
        url: "/item/:itemId",
    });

Each state's templates where made as widget.

<div container>
    <div header></div>
    <div body></div>
</div>
<ui-view  />

But i don't know how to append new states to current state. Say i have another states:

    .
    state('asd', {
        url: "/asd",
    }).
    state('asd.ref', {
        url: "/ref",
    });

When i navigate to /asd from / i see right state. But i want to navigate to this state from

/azured/ref/tableId/12/listId/3/itemId/434

and don't destroy current widgets but append

(make url as /azured/ref/tableId/12/listId/3/itemId/434/asd)

(please note asd). Just want to append new state to the current state and go on further. Guess i can hardcode all possible branches, but need better solution.

Here is preview
enter image description here

@mastilver
Copy link

I think it's a duplicate of: #384

I would create a function which generate states:

function generateState(parent){
$stateProvider
.state(parent + 'asd', {
parent: parent,
// ... constant controller, template...
}
.state(parent + 'asd.ref', {
// childreen
}
}

@vko-online
Copy link
Author

The problem is that i should be able to go from

/azured/ref/tableId/12/listId/3/itemId/434

or

/azured/ref/tableId/12/listId/3

or

/azured/ref/tableId/12

or

/azured/ref/

So for each state i dont want to create state for my /asd as i think it's not correct?

@mastilver
Copy link

an another option would be to use this url for the asd state

url: '*path/asd'

I prefer my first solution.
If you find anything else, please let me know!

@vko-online
Copy link
Author

url: '*path/asd'

Doesn't work, it redirects to localhost:9000/#/asd, only url: '*path' works and doesn't change url, but the problem is that it removes old html markup from DOM, where old <ui-view />'s are already rendered, Is there a way to append new state markup to existing <ui-view />?? So that all state templates would nest each other

@vko-online
Copy link
Author

Made a demo http://screencast.com/t/nXcc1fuiL9G

@mastilver
Copy link

Yes, of course, I forget you needed to keep previous state...
For me the only solution is the first one

@christopherthielen
Copy link
Contributor

@vko-online I am struggling to understand what you are trying to do. Do you want an "asd" state that can be appended to all other states?

@vko-online
Copy link
Author

@christopherthielen yes, thats right, i wanted to make infinite nesting, but guess it's not possible, so i now implementing deepStates (very very useful btw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants