Skip to content

Instantly share code, notes, and snippets.

@e00dan
Last active February 5, 2016 17:56
Show Gist options
  • Save e00dan/02ea221e1ee3c5cb662c to your computer and use it in GitHub Desktop.
Save e00dan/02ea221e1ee3c5cb662c to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
queryParams: {
locale: {
refreshModel: true
}
},
locale: null
});
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel(transition) {
console.log('before model');
if (transition.queryParams.locale == null) {
Ember.run.next(() => transition.send('switchLocale', 'en'));
}
},
actions: {
switchLocale(locale) {
this.controllerFor('application').set('locale', locale);
this.refresh();
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
Locale: `{{locale}}` <br/>
{{#link-to 'foo.bar'}}Go to foo bar{{/link-to}}
{{outlet}}
<br>
<br>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('foo', function() {
this.route('bar');
});
});
export default Router;
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"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