Skip to content

Instantly share code, notes, and snippets.

@nickiaconis
Last active August 11, 2016 18:40
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 nickiaconis/4305c74c6db26f4e00cbc0129d32f5b9 to your computer and use it in GitHub Desktop.
Save nickiaconis/4305c74c6db26f4e00cbc0129d32f5b9 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: ['foo', 'bar'],
foo: null,
bar: null,
});
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel(transition) {
if (!transition.queryParams.foo && !transition.queryParams.bar) {
transition.abort();
this.transitionTo('application', {
queryParams: {
bar: 'baz',
foo: 'fiz',
},
});
}
},
model(params) {
return {
params: JSON.stringify(params),
};
},
});
<h1>Welcome to {{appName}}</h1>
<p>controller->foo: {{foo}}</p>
<p>controller->bar: {{bar}}</p>
<p>route->model->params: {{model.params}}</p>
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment