Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
Created August 29, 2017 17:27
Show Gist options
  • Save nathanhammond/62dabaeb70b7c27a81d9656e15bd8647 to your computer and use it in GitHub Desktop.
Save nathanhammond/62dabaeb70b7c27a81d9656e15bd8647 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['something'],
filter: null,
actions: {
reloadList() {
this.transitionToRoute('list.details', { queryParams: { filter: 'hello' } });
},
reloadDetails() {
this.transitionToRoute('list.details', { queryParams: { something: 'hello' } });
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['filter'],
filter: null
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('list', function() {
this.route('details');
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
something: {
refreshModel: true
}
},
model() {
return new Ember.RSVP.Promise(function(resolve) {
setTimeout(function() {
resolve({ "hello": "world" });
}, 2000);
});
}
});
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
filter: {
refreshModel: true
}
},
model() {
return new Ember.RSVP.Promise(function(resolve) {
setTimeout(function() {
resolve({ "hello": "world" });
}, 2000);
});
}
});
<h1>Application</h1>
<nav>
<ul>
<li>{{#link-to "application"}}application{{/link-to}}</li>
<li>{{#link-to "list.details"}}list.details{{/link-to}}</li>
</ul>
</nav>
<hr />
{{outlet}}
<h3>Details</h3>
{{model.hello}}
<button onclick={{action "reloadList"}}>Reload List</button>
<button onclick={{action "reloadDetails"}}>Reload Details</button>
<h2>List</h2>
{{model.hello}}
<hr />
{{outlet}}
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment