Nested States
Nested states allow you to build hierarchical application structures where child states inherit configuration from parent states. This is one of UI-Router’s most powerful features.State Hierarchy Basics
States can be nested using dot notation in the state name:app(/app)app.dashboard(/app/dashboard)app.dashboard.stats(/app/dashboard/stats)
Dot Notation
Dot notation automatically creates parent-child relationships:- Child state names must start with parent name + dot
- Parent state must exist before registering child
- Dots create the hierarchy, not the URL structure
Explicit Parent Declaration
Alternatively, explicitly set the parent:- Shorter state names (“settings” vs “app.user.settings”)
- Dynamic state registration
- Avoiding deep nesting in state names
URL Inheritance
Child URLs are appended to parent URLs:app:/appapp.users:/app/usersapp.users.detail:/app/users/123
Absolute URLs
Override URL inheritance with^:
Parameter Inheritance
Child states inherit parent parameters:Resolve Inheritance
Child states can use parent resolves:Data Inheritance
Thedata property uses prototypal inheritance:
Abstract States
Abstract states cannot be activated directly but provide shared configuration:- Shared layouts
- Common resolves
- Authentication wrappers
- Shared URL prefixes
View Nesting
Nested states create nested views (framework-specific):State Activation
When activating a child state, all parent states activate:State Retention
States are retained when navigating between siblings:Relative Navigation
Navigate relative to current state:Common Patterns
Application Layout Pattern
Feature Module Pattern
Tab Navigation Pattern
Multi-Level Data Pattern
Best Practices
// Good - abstract parent provides layout
{
name: 'app',
abstract: true,
component: LayoutComponent
}
// Avoid - repeating layout in each state
// Good - 3 levels
'app.users.detail'
// Avoid - too deep
'app.admin.workspace.users.detail.settings.preferences'
// Good - grouped by feature
'products.list'
'products.detail'
'products.edit'
// Less organized
'productList'
'productDetail'
'productEdit'
Related Documentation
- State Configuration - Configure individual states
- Navigation - Navigate between nested states
- URL Routing - URL composition in hierarchies
- Resolve - Resolve inheritance
API Reference
- StateDeclaration - State configuration including
parentandabstract - StateRegistry - Register nested states
- StateObject - Access state hierarchy information