angular-ui-router State transition Use $state.go to transition between states

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

$state.go is shorthand method to $state.transitionTo

$state.go(toState [, toParams] [, options])

This method automatically sets your options to { location: true, inherit: true, relative: $state.$current, notify: true } (unless you override them) and allows you to transition with less code.

Examples:

Lets say we have an app with a 'main' state, with 2 child states: 'dashboard' and 'help', and 'dashboard' also has a child called 'about'.

Transition to another state

$state.go("main.dashboard") // from anywhere to 'main.dashboard'

Transition to parent state

$state.go("^") // from 'main.dashboard' to 'main'

You can also transit to another child of the parent state (sibling)

$state.go("^.help") // from 'main.dashboard' to main.help

Placing a . will allow you to transition to child states

$state.go(".about") // from 'main.dashboard' to 'main.dashboard.about'


Got any angular-ui-router Question?