Michael St Clair
Michael St Clair

Reputation: 6615

How to put routes in a sub folder without changing the URL in Ember

I have links that currently are in my main path. I would like to group them in a sub folder without changing the urls. For example I have /income-statement and I want to put the files in a reports directory. With the nested routes the url becomes /reports/income-statement. I tried setting the path on the reports level to be {path: ''} but it conflicts with my main route

this.route('reports', function() {
  this.route('accounts-receivable')
  this.route('income-statement')
})

Upvotes: 1

Views: 147

Answers (2)

Lux
Lux

Reputation: 18240

Specify the path of your group-route to be /:

this.route('reports', { path: '/' }, function() {
  this.route('accounts-receivable')
  this.route('income-statement')
});

Upvotes: 1

Michael St Clair
Michael St Clair

Reputation: 6615

I figured out I can accomplish this by adding ../ to the beginning of the path

this.route('reports', function() {
  this.route('accounts-receivable', {path: '../accounts-receivable'})
  this.route('income-statement', {path: '../income-statement'})
})

Upvotes: 1

Related Questions