Hi folks,
Is there a way to have dynamic segments on root routes with some exclusion pattern?
I`d like to do something as:
mydomain.com/:project_shortname → dynamic segment for project route and model
mydomain.com/admin → route for admin
Is there a plugin or some idea in how to implement it?
Thank u a lot guys!!!
broerse
September 22, 2015, 5:04am
2
I don’t know if it is the best way but we use the route
below. posts.hbs
just contains an outlet. You can do an if in the post.hbs
for the admin part like this https://github.com/broerse/outlet-inside-each/blob/master/app/templates/components/posts-list.hbs with ember-truth-helpers
export default Router.map(function() {
this.route('posts', { path: '/' }, function() {
this.route('post', { path: '/:site_id', resetNamespace: true });
});
});
Perhaps you can just add a route for /admin
before the /:site_id
but I have not done this yet.
JS Bin - Collaborative JavaScript Debugging this can be achieved without excluding.
If you really want exclusion you could a check in the product route’s beforeModel
hook to check the params for the presence of admin
and abort and transition to your admin route.