Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Last active August 17, 2016 11:28
Show Gist options
  • Save kumkanillam/70da9234bcd5369d894d5a4192027cc1 to your computer and use it in GitHub Desktop.
Save kumkanillam/70da9234bcd5369d894d5a4192027cc1 to your computer and use it in GitHub Desktop.
Demo Dynamic Segments
import Ember from 'ember';
export default Ember.Component.extend({
name:'',
init(){
this._super(...arguments);
this.set('name','my-table');
console.log('init');
},
willUpdate(){
this._super(...arguments);
console.log('willupdate');
},
actions:{
updateName(){
this.set('name','lewis');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
reportId:'',
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('reports',{path:'reports/:reportId'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params){
var result ={};
result.reportId=params.reportId;
result.result = 'result';
return result;
},
setupController(controller,model){
this._super(...arguments);
controller.set('reportId',model.reportId);
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
My-table-{{reportId}} - {{name}} <button {{action "updateName" }}> Update Name </button>
{{yield}}
Reports-{{reportId }}
{{my-table reportId=reportId}}
{
"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