Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
Last active July 25, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanhammond/50f46894687604c29da848b150c02e31 to your computer and use it in GitHub Desktop.
Save nathanhammond/50f46894687604c29da848b150c02e31 to your computer and use it in GitHub Desktop.
paramsFor Child
import Ember from 'ember';
export default Ember.Controller.extend({
value: {
id: 12,
name: 'james'
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('parent', function() {
this.route('child', { path: '/child/:child_id' });
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return {
id: 12,
name: 'james'
};
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.paramsFor('parent.child');
}
});
<h1>Application</h1>
{{#link-to 'parent.child' 12}}parent.child{{/link-to}}
<hr />
{{outlet}}
<h3>Child</h3>
{{model.name}}
<h2>Parent</h2>
{{model.child_id}}
<hr />
{{outlet}}
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment