Skip to content

Instantly share code, notes, and snippets.

@ro0gr
Last active May 10, 2018 21:31
Show Gist options
  • Save ro0gr/efda3c9e57835c987404a8f5968c7579 to your computer and use it in GitHub Desktop.
Save ro0gr/efda3c9e57835c987404a8f5968c7579 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
router: Ember.inject.service(),
queryParams: ['test'],
test: `I'm changed o_O`,
actions: {
transitionWithRouterService() {
// do not touch "test" in the transition
// but it got changed on the "application" route
this.get('router').transitionTo('in')
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('in');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
test: {
refreshModel: true
}
},
model(params, {queryParams}) {
alert(`I should only appear on page load!
Query Param Value: ${queryParams.test}
`)
}
});
<h1>RouterService + default QueryParams</h1>
<p>
<code>RouterService.transitionTo()</code> doesn't take into account default <code> queryParams </code> values which triggers a model refresh on the parent route.
</p>
<a href="javascript:;"
onclick={{action "transitionWithRouterService"}}
>
RouterService.transitionTo('in')
</a>
{{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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment