Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Forked from mpugach/controllers.application.js
Created November 11, 2020 15:49
Show Gist options
  • Save rwjblue/2d80d71daa9a9a99676aef471cb55b90 to your computer and use it in GitHub Desktop.
Save rwjblue/2d80d71daa9a9a99676aef471cb55b90 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: ['categories', 'serachQuery'],
categories: [],
serachQuery: '',
actions: {
addCategory() {
this.get('categories').pushObject(1);
}
},
});
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
categories: {
type: 'array',
refreshModel: true,
},
searchQuery: {
refreshModel: true,
}
},
model(params) {
console.log('categories', params.categories);
return new Promise(resolve => setTimeout(resolve, 1000)).then(() => new Date);
},
actions: {
willTransition() {
console.log('willTransition');
},
didTransition() {
console.log('didTransition');
},
},
});
<h1>Welcome to {{appName}}</h1>
<br>
{{model}}
<br>
<button {{action "addCategory"}}>Add category</button>
<br>
{{input value=searchQuery}}
<br>
<br>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"ember": "3.22.1",
"ember-template-compiler": "3.22.1",
"ember-testing": "3.22.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment