Reputation: 1829
What is the difference between route and path in EmberJs
Router.map(function () {
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
});
Upvotes: 1
Views: 34
Reputation: 2459
The first argument to route
is the name of the route. It's used to find the right files to load app/routes/about.js
and to provide links <LinkTo @route="about">About</LinkTo>
. If you provide a path
option it is used to create the URL you see in the location bar for the browser.
From the ember guides
You can leave off the path if it is the same as the route name.
For your case the following are equivalent:
Router.map(function () {
this.route('about', { path: '/about' });
this.route('contact', { path: '/getting-in-touch' });
});
Router.map(function () {
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
});
Will results in Ember knowing how to load URLs for https://yoursite.com/about
and https://yoursite.com/getting-in-touch
And for <LinkTo @route="contact">Contact Us</LinkTo>
to create a link with HTML like <a href="https://yoursite.com/getting-in-touch">Contact Us</a>
Upvotes: 5