Skip to content

Instantly share code, notes, and snippets.

@marg51
Created September 10, 2016 14:33
Show Gist options
  • Save marg51/9ca3ce019bba41f0d0a2728e3aec86ab to your computer and use it in GitHub Desktop.
Save marg51/9ca3ce019bba41f0d0a2728e3aec86ab to your computer and use it in GitHub Desktop.
List all URLs of your app from ui-router
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