Skip to content

Instantly share code, notes, and snippets.

@bantic
Created November 29, 2018 17:24
Show Gist options
  • Save bantic/5a22a65e69964031f493d3e45b18ae44 to your computer and use it in GitHub Desktop.
Save bantic/5a22a65e69964031f493d3e45b18ae44 to your computer and use it in GitHub Desktop.
Route-Recognizer Issue #145 with Dynamic
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('worker', {
path: '/:worker'
}, function () {
this.route('city', {
path: '/:city'
});
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
setupController(controller, model) {
controller.setProperties({
worker: this.modelFor('worker').worker,
city: model.city
});
console.log('city route');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
setupController(controller, model) {
controller.set('model', model);
console.log('worker route');
}
});
<h1>Welcome to {{appName}}</h1>
<p>Demo for <a href='https://github.com/tildeio/route-recognizer/issues/145#issuecomment-441871738'>issue #145</a> in route-recognizer with dynamic path segments</p>
<br>
Go to {{#link-to 'worker.city' 'praca-sprzątanie' 'kczewo'}}/praca-sprzątanie/kczewo{{/link-to}}<br>
Go to {{#link-to 'index'}}/{{/link-to}}
<br>
{{outlet}}
<br>
<br>
<h1>worker/city.hbs</h1>
Worker: <b>{{worker}}</b><br>
City: <b>{{city}}</b><br>
{
"version": "0.15.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": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment