Skip to content

Instantly share code, notes, and snippets.

@lukecoy
Created June 20, 2018 00:41
Show Gist options
  • Save lukecoy/e8ee7e7aaf13803efa8598edf14ae3c9 to your computer and use it in GitHub Desktop.
Save lukecoy/e8ee7e7aaf13803efa8598edf14ae3c9 to your computer and use it in GitHub Desktop.
Transitioning to a route (declared first) with the same path name doesn't work (Check the console)
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo', { path: '/' }) // Try changing this to a different path than "bar" route. Then, it will work.
this.route('bar', { path: '/' })
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
// This will throw an exception when I try to do this because "foo" route has the same exact path.
// BUT, if I change foo's path (e.g. - "/foo"), then it will transition correctly.
this.transitionTo('foo');
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
This is the bar route!
This is the foo route!
{
"version": "0.14.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"ember-data": "2.18.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment