Skip to content

Instantly share code, notes, and snippets.

@twokul
Last active August 11, 2016 15:10
Show Gist options
  • Save twokul/cabe09d30ec9c9ec9e20265e9841848a to your computer and use it in GitHub Desktop.
Save twokul/cabe09d30ec9c9ec9e20265e9841848a to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('index', { path: '/' }, function() {
this.route('explore');
this.route('insights', { path: '/:id' });
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
title: {
refreshModel: true
},
location: {
refreshModel: true
}
},
model() {
return this.modelFor('index');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel(transition) {
console.log(transition.targetName, 'beforeModel');
},
model() {
console.log('model');
return {
id: 'business-analyst-salaries-in-greater-chicago-area'
};
},
afterModel() {
this.transitionTo('index.explore', {
queryParams: {
title: 'business analyst',
location: 'greater chicago area'
}
});
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<p>main page content</p>
{{yield}}
<h2>Explore</h2>
Title: {{model.title}}
Location: {{model.location}}
<h1>Index</h1>
{{link-to "Insights" "index.insights" model}}
{{link-to "Explore" "index.explore" (query-params title="business analyst" location="greater chicago area")}}
{{outlet}}
{
"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