Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS ui-router doesn't work with nested views
    primarykey
    data
    text
    <p>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:</p> <pre><code>1. home.html &lt;html ng-app="app"&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-controller="MainCtrl"&gt; &lt;ul&gt; &lt;li &gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li &gt;&lt;a href="#/user"&gt;List Users&lt;/a&gt;&lt;/li&gt; &lt;li &gt;&lt;a href="#/products"&gt;List Products&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div &gt; &lt;div ui-view&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="angular.js"&gt;&lt;/script&gt; &lt;script src="angular-ui-router.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; 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 &lt;div&gt; &lt;ul&gt; &lt;li ng-repeat="user in userList "&gt; &lt;a href="#/user/edit/{{user.uid}}"&gt;{{user.name}}&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div&gt; &lt;a href="#/user/add"&gt;&lt;button&gt;New User&lt;/button&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload