Skip to content

Instantly share code, notes, and snippets.

@Sinled
Last active April 14, 2018 07:31
Show Gist options
  • Save Sinled/fdca5ba207fa09142a6be91d4e9cc247 to your computer and use it in GitHub Desktop.
Save Sinled/fdca5ba207fa09142a6be91d4e9cc247 to your computer and use it in GitHub Desktop.
nested-query-params
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: [
{ field: { type: 'array', as: 'child-field' } },
{ page: { type: 'string', as: 'child-page' } },
],
field: ['bar'],
page: '2',
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: [
{ field: { type: 'array', as: 'parent-field' } },
{ page: { type: 'string', as: 'parent-page' } },
],
field: ['foo'],
page: '1',
});
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')
})
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.active {
font-weight: bold;
}
<h1>Welcome to {{appName}}</h1>
<br>
<hr>
<br>
{{#link-to 'parent' (query-params parent-page=5) }}Visit Parent route{{/link-to}} | {{#link-to 'parent.child' }}Visit Child route{{/link-to}}
{{outlet}}
<br>
<br>
<h5>Child route</h5>
Child field: {{field}} <br>
Child page: {{page}}
<h3>Parent Route</h3>
Parent field: {{field}} <br>
Parent page: {{page}}
<hr>
{{outlet}}
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment