Object to route
{
"version": "0.8.1",
"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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
<p>In POST {{model.id}}</p>
{{model.msg}}
<hr>
<p>Comment : {{outlet}}</p>
<button {{action 'toComment' 1 }}>Comment 1</button>
<button {{action 'toComment' {id:2, cmt: 'Awesome movie'} }}>Comment 2</button>
<button {{action 'toComment' {id:3, cmt: 'OK.. Not great'} }}>Comment 3</button>
<strong> {{model.cmt}}</strong>
<h1>Welcome to {{appName}}</h1>
<br>
<button {{action 'topost'}}>TO POST</button>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return params;
},
actions: {
toComment(params) {
this.transitionTo('comment', params)
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return params;
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('post', {path: '/post/:id'});
this.route('post', {path: '/comment/:id'});
});
export default Router;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
topost() {
this.transitionToRoute('post', {id: 2, msg: 'A successful transition'});
}
}
});