Want to defining routes with custom paths in EmberJS? We’re on a roll! While we’re at it, let’s add our third page. This time, things are a little bit different. Everyone at the company calls this the “contact” page. However, the old website we are replacing already has a similar page, which is served at the legacy URL /getting-in-touch.
We want to keep the existing URLs for the new website, but we don’t want to have to type getting-in-touch all over the new codebase! Fortunately, we can have the best of the both worlds:
1 2 3 4 5 6 7 8 9 10 11 12 | import EmberRouter from '@ember/routing/router'; import config from './config/environment'; export default class Router extends EmberRouter { location = config.locationType; rootURL = config.rootURL; } Router.map(function() { this.route('about'); this.route('contact', { path: '/getting-in-touch' }); }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.