Skip to content

Instantly share code, notes, and snippets.

@mszoernyi
Last active February 27, 2016 22:53
Show Gist options
  • Save mszoernyi/356c1488fb8e6733ac06 to your computer and use it in GitHub Desktop.
Save mszoernyi/356c1488fb8e6733ac06 to your computer and use it in GitHub Desktop.
Query Param test
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
queryParams: ['category'],
category: 1
});
import Ember from 'ember';
export default Ember.Route.extend({
setupController(controller, context) {
this._super(controller, context);
// adds the query param to the url
Ember.RSVP.Promise.resolve().then(() => {
//controller.set('category', 23);
});
// this doesn't
controller.set('category', 23);
},
});
<h1>Query Param test</h1>
<p>
My expectaion is the url gets automatically the configured query param added.
</p>
<p>application/route.js updates the query param in two ways
<br><br>
1. inside a promise<br>
2. directly via set on the controller
<br><br>
I would expect both work but only the promise version updates the url.
</p>
{{outlet}}
<br>
<br>
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr(),
});
{
"version": "0.4.17",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment