Skip to content

Instantly share code, notes, and snippets.

@misterbyrne
Created March 25, 2020 11:07
Show Gist options
  • Save misterbyrne/d65676dc8d9e72690c9546c3310ff7ae to your computer and use it in GitHub Desktop.
Save misterbyrne/d65676dc8d9e72690c9546c3310ff7ae to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class MyComponent extends Component {
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class MyRouteController extends Controller {
@tracked x = [];
get jsonX() {
return JSON.stringify(this.x);
}
@action
increment() {
this.x.pushObject(this.x.length);
}
}
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');
});
export default Router;
import Route from '@ember/routing/route';
export default Route.extend({
queryParams: {
x: { refreshModel: true },
y: { refreshModel: true }
},
model(params) {
return JSON.stringify(params);
}
});
<h1>Welcome to {{this.appName}}</h1>
<br>
<br>
<LinkTo @route="my-route" >My route</LinkTo><br>
{{outlet}}
<br>
<br>
{{@x}}
<button {{on "click" @increment}}>Increment</button>
This is the template for my-route
<div>
x: {{this.x}}
y: {{this.y}}
</div>
model: {{@model}}
<MyComponent @x={{this.x}} @increment={{this.increment}}/>
<br>
JSON here:
{{this.jsonX}}
{
"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.17.0",
"ember-template-compiler": "3.17.0",
"ember-testing": "3.17.0"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment