Skip to content

Instantly share code, notes, and snippets.

@patrickberkeley
Last active February 6, 2016 07:54
Show Gist options
  • Save patrickberkeley/be20d289a4f5dc945580 to your computer and use it in GitHub Desktop.
Save patrickberkeley/be20d289a4f5dc945580 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
somethingDownFromController: null
});
import Ember from 'ember';
const {
set
} = Ember;
export default Ember.Route.extend({
actions: {
sendSomethingUp(something) {
set(this.controllerFor('application'), 'somethingDownFromController', something);
}
}
});
<div class="page">
<aside class="sidebar">
{{outlet}}
</aside>
<div class="content">
{{places-map
something=somethingDownFromController
}}
</div>
</div>
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return {
somethingFromNestedRoute: 'boooooyaaaaah'
}
}
});
<hr>
<strong>/place/:id template</strong>
<div>
<button {{action 'sendSomethingUp' model.somethingFromNestedRoute}}>
Send model up
</button>
</div>
import Ember from 'ember';
export default Ember.Component.extend({
});
<hr>
<strong>places-map template</strong>
<div>
And insert something from the outer context:
<div>{{something}}</div>
</div>
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
// You shouldn't need this route.
// The index route is the default
// that gets used. so unless you
// need there to be some content
// that displays on the initial load,
// but not on subsequent loads, you
// don't need the index route.
// this.route('index', { path: '/' });
this.route('place', { path: "/place/:place_id" });
this.route('places');
// I'd suggest making these nested:
//
// this.route('places', function() {
// this.route('show', { path: "/:place_id" });
// });
});
export default Router;
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment