Skip to content

Instantly share code, notes, and snippets.

@k-fish
Last active April 13, 2020 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-fish/c982a31972588722269b1965f7a7961a to your computer and use it in GitHub Desktop.
Save k-fish/c982a31972588722269b1965f7a7961a to your computer and use it in GitHub Desktop.
Routing example
import Component from '@ember/component';
export default Component.extend({
baseProperty: 'hello'
});
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Controller from '@ember/controller';
import { computed } from '@ember/object';
export default Controller.extend({
foo: computed.alias('model.foo')
});
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('my-route', { path: '/' });
});
export default Router;
import Route from '@ember/routing/route';
import { getOwner } from '@ember/application';
export default Route.extend({
model() {
return {
foo: 'bar'
};
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.red {
background-color: rgb(255,0,0,0.5);
}
.blue {
background-color: rgb(0,0,255,0.5);
}
.green {
background-color: rgb(0,255, 0,0.5);
}
article {
padding: 20px;
border-radius: 10px;
}
<article class="red">
<h1>Basic Application</h1>
<br>
<br>
{{outlet}}
<br>
<ul>
<li>
{{#link-to 'application'}} Index {{/link-to}}
</li>
<li>
{{#link-to 'my-route'}} Link to my route {{/link-to}}
</li>
</ul>
<br>
</article>
<article class="green">
My Component, properties: {{baseProperty}}, {{providedProperty}}
</article>
<article class="blue">
<h3>My Route</h3>
<div>
Output of controllers model.foo: {{model.foo}}
</div>
<div>
Output of controllers foo: {{foo}}
</div>
{{my-component providedProperty='world'}}
</article>
{
"version": "0.17.0",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.9.1",
"ember-template-compiler": "3.9.1",
"ember-testing": "3.9.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment