Skip to content

Instantly share code, notes, and snippets.

@meirish
Forked from amk221/router.js
Last active July 28, 2017 15:55
Show Gist options
  • Save meirish/2d1dbb37f3e3001c9ff63fe55015f338 to your computer and use it in GitHub Desktop.
Save meirish/2d1dbb37f3e3001c9ff63fe55015f338 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo', { path: '/foo/:topId' }, function() {
this.route('nested', { path: '/nested/:nestedId' });
});
this.route('bar', function() {
this.route('nested');
});
});
Ember.Route.reopen({
setupController() {
this._super(...arguments);
this.controllerFor('application')
.set('routeName', this.get('routeName'));
}
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
a.active {
font-weight: bold;
}
Current route: {{routeName}}
<br><br>
Does not work with params:
{{#link-to 'foo' 1 current-when='foo.index'~}}
foo.index
{{~/link-to}} |
{{#link-to 'foo' 2~}}
foo.nested
{{~/link-to}}
<br><br>
{{outlet}}
Bar
<br><br>
{{outlet}}
-> Nested
<br><br>
{{outlet}}
Foo {{model.topId}}
<br><br>
{{outlet}}
-> Nested {{model.nestedId}}
<br><br>
{{outlet}}
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment