Skip to content

Instantly share code, notes, and snippets.

@rinoldsimon
Last active April 22, 2019 05:13
Show Gist options
  • Save rinoldsimon/72d68e3103b90cae6540c92bdc83c29c to your computer and use it in GitHub Desktop.
Save rinoldsimon/72d68e3103b90cae6540c92bdc83c29c to your computer and use it in GitHub Desktop.
pass id in route
import Ember from 'ember';
export default Ember.Controller.extend({
appName: "Ember Twiddle"
})
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('posts', function() {
this.route('edit', { path: '/:post_id/edit' });
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
alert('hit this when update post is clicked. Post id is :'+params.post_id)
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#link-to "posts.edit" 3}}Update post{{/link-to}}
<br>
{{outlet}}
<br>
<br>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment