Created
September 10, 2016 14:33
-
-
Save marg51/9ca3ce019bba41f0d0a2728e3aec86ab to your computer and use it in GitHub Desktop.
List all URLs of your app from ui-router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.run( ($state) => { | |
const indexed_state = {} | |
const states = $state.get() | |
states.forEach( state => { | |
indexed_state[ state.name ] = state | |
}) | |
const URLs = states.map( state => getUrlOf(state) ) | |
function getUrlOf(object) { | |
const list = object.name.split(".") | |
if(list.length > 1) | |
return getUrlOf( indexed_state[ list.slice(0,-1).join('.') ]) + (object.url || "") | |
return (object.url || "") | |
} | |
console.log( JSON.stringify( URLs , null, 4) ) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment