I user ui-router for my application. In my application, click User navigation bar will navigate to a screen for a list of users. At this screen, if clicking a user it goes to User Edit screen, if clicking New User button it goes to Add User screen. I route them as below:
1. home.html
<html ng-app="app">
<head>
</head>
<body>
<div ng-controller="MainCtrl">
<ul>
<li ><a href="#">Home</a></li>
<li ><a href="#/user">List Users</a></li>
<li ><a href="#/products">List Products</a></li>
</ul>
</div>
<div >
<div ui-view></div>
</div>
</div>
<script src="angular.js"></script>
<script src="angular-ui-router.js"></script>
</body>
</html>
2. app.js
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/user')
$stateProvider.
state('user',
{url: '/user', templateUrl: 'views/user-list.html', controller: UserListController}).
state('user.edit',
{url: '/user/edit/:userId', templateUrl: 'views/user-edit.html', controller: UserEditController}).
state('add',
{url: '/user/add', templateUrl: 'views/user-add.html', controller: UserAddController})
});
3. user-list.html
<div>
<ul>
<li ng-repeat="user in userList ">
<a href="#/user/edit/{{user.uid}}">{{user.name}}</a>
</li>
</ul>
</div>
<div>
<a href="#/user/add"><button>New User</button></a>
</div>
The problem raises with naming state for edit route. If I choose name 'user.edit' with 'user' part is exactly the name of list state, then click edit link, ui-router can't route to edit page. If I choose a name without hierachy to 'user', say 'edit' or 'change' for edit state, it works. Also, in case of add route, I name 'add', it works. Am I wrong something? Please advice.