State Configuration
States are the fundamental building blocks of UI-Router. This guide covers all configuration options available when defining states.Basic State Definition
A state is defined using aStateDeclaration object with a unique name:
Core Configuration Options
Name (Required)
Thename property uniquely identifies the state:
URL Pattern
Define the URL fragment for the state:Parent State
Explicitly define a parent state:Abstract States
Abstract states cannot be directly activated but provide shared configuration:Parameter Configuration
Define and configure state parameters:type: Parameter type (string, int, date, etc.)value: Default valuearray: Treat as array of valuessquash: Omit default values from URLdynamic: Don’t reload state when changedraw: Disable URL encodinginherit: Control parameter inheritance
Resolve - Async Data Loading
Fetch data before activating the state:Object Syntax
Array Syntax (Advanced)
Resolve Policy
Control when and how resolves are fetched:Data - State Metadata
Store arbitrary metadata that child states inherit:Redirect
Automatically redirect when entering a state:Lifecycle Hooks
Define hooks that run during state transitions:Lazy Loading
Load state code and definitions on-demand:Dynamic States
Mark all parameters as dynamic to prevent state reload:Views Configuration
Target named views (framework-specific):Complete Example
A fully configured state with all options:Best Practices
Related Documentation
- Navigation - Navigate between states
- Parameters - Work with state parameters
- Nested States - Build state hierarchies
- URL Routing - Configure URL patterns
- Resolve - Async data loading
- Transition Hooks - Lifecycle management
API Reference
- StateDeclaration - Complete state configuration interface
- StateRegistry - Register and manage states
- StateService - Access current state information