Closed
Description
Currently there are 3 ways of defining states:
- Using 'dot' notation. For example
name: 'contacts.list'
- Using the parent property with the parent name as string. For example:
parent: 'contacts'
- Using the parent property with the parent object. For example
parent: contacts
(where 'contacts' is an stateObject)
To me it would make sense to also support a 'children' property. This would be used as follows:
$stateProvider
.state('contacts', {
children: [
{
name: 'list'
}
]
});
In the end it is all a matter of preference. I don't think it matters a lot which ways are supported. Currently I use the following function to support the method described above.
function setState(state){
$stateProvider.state(state);
if(state.children && state.children.length){
state.children.forEach(function(childState){
childState.parent = state;
setState(childState);
});
}
}
What would be more useful is the fact that you would have the children property available afterwards. This way a state would know which children it has. Which would allow for things like:
<ul>
<li ng-repeat='childState in $state.current'>
<a ui-sref='childState.name'>{{ childState.name }}</a>
</li>
</ul>