Skip to content

Instantly share code, notes, and snippets.

@joeltrew
Created December 14, 2015 00:28
Show Gist options
  • Save joeltrew/ca25ef6d189ec5baf14b to your computer and use it in GitHub Desktop.
Save joeltrew/ca25ef6d189ec5baf14b to your computer and use it in GitHub Desktop.
pass data with transition
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
transition: function() {
this.transitionToRoute('newroute', {id: 1, model: 123});
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<button {{action 'transition'}}>transition</button>
<br>
<br>
import Ember from 'ember';
export default Ember.Route.extend({
serialize: function(model) {
return { id: model.id };
},
setupController(controller, model) {
controller.set('data', model)
this._super(controller, model)
},
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('newroute', {path: 'newroute/:id'});
});
export default Router;
{
"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