angular-ui-router
  • Introduction
  • Configuring State
  • Activating State
  • Named Views
  • Nested State
  • onEnter onExit
  • Passing Data
  • Resolve Property
  • State Params
  • State Service
  • State Events
  • Abstract State
Powered by GitBook
On this page
  • $state
  • Demo
  • ui-sref ( same as $state.go but used in html )

Was this helpful?

Activating State

3 ways

$state.go("classroom");
<a ui-sref="classroom">Class Room</a>
<a href="/classroom">Class Room</a>

$state

$state.go(to, [toParams], [options]);

to - required string (state name, use ^, . for relative paths )
toParams - optional parameter object 
options (optional object )
    - location ('replace/true/false' default true)
    - inherit  // true (default)
    - relative // $state.current
    - notify // true (if false stateChangeStart & stateChangeSuccess not notified)
    - reload // false ( if true force reload of state even parameter not changed  )

Demo

$state.go("photos.detail") 

// now current state is "photos.detail"
$state.go("^") // goes to state "photos"
$state.go("^.list") // goes to sibling state ("photos.list")
$state.("^.detail.comment") // goes to "photos.detail.comment"

ui-sref ( same as $state.go but used in html )

ui-sref="stateName"
ui-sref="stateName({param1: val1, param2: val2})"
PreviousConfiguring StateNextNamed Views

Last updated 5 years ago

Was this helpful?