Nested routes in Amber

I want the settings area to look like this:

.. /settings/:accountId/users /settings/:accountId/users/:userId 

My router is defined as follows:

 Router.map(function() { this.route('login'); this.resource('settings', { path: 'settings/:settings_id' }, function() { this.route('overview'); this.route('users'); }); }); 

This works to display the user list page. I'm not sure how to do this in the next step, although it has both a route and a resource for /users and /users/1 .

Thanks.

+1
source share
1 answer

In recent versions of Ember, a route may have a sub-item (for a namespace).

 Router.map(function() { this.route('login'); this.resource('settings', { path: 'settings/:settings_id' }, function() { this.route('overview'); this.route('users', function(){ this.route('user', {path:':user_id'}); }); }); }); 

http://emberjs.jsbin.com/cutayuniga/1/edit?html,js,output

If you are in the old version, you will need to make the resource users.

 Router.map(function() { this.route('login'); this.resource('settings', { path: 'settings/:settings_id' }, function() { this.route('overview'); this.resource('users', function(){ this.route('user', {path:':user_id'}); }); }); }); 
+2
source

Source: https://habr.com/ru/post/1210239/


All Articles