Skip to content

Instantly share code, notes, and snippets.

@feanor07
Last active June 26, 2017 17:56
Show Gist options
  • Save feanor07/47c0f2499c4035e05b230c88fda2528a to your computer and use it in GitHub Desktop.
Save feanor07/47c0f2499c4035e05b230c88fda2528a to your computer and use it in GitHub Desktop.
so#44759267
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['fin', 'ftw', 'additionalParams'],
actions: {
updateFin() {
this.set('fin', `val${Math.random()}`);
},
updateFtw() {
this.set('ftw', `val${Math.random()}`);
},
updateAdditionalParams() {
let dynamicProperty = `prop${Math.random()}`;
let val1= `val${Math.random()}`;
let val2 = Math.random();
let val3 = new Date();
let json = {prop2: val2, prop3: val3};
json[dynamicProperty] = val1;
this.set('additionalParams', JSON.stringify(json));
},
clearAll() {
this.set('fin', undefined);
this.set('ftw', undefined);
this.set('additionalParams', undefined);
},
clearFin() {
this.set('fin', undefined);
},
clearFtw() {
this.set('ftw', undefined);
},
clearAdditionalParams() {
this.set('additionalParams', undefined);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<button onclick={{action 'clearAll'}}>Clear All</button>
<button onclick={{action 'updateFin'}}>Update Fin</button>
<button onclick={{action 'clearFin'}}>Clear Fin</button>
<button onclick={{action 'updateFtw'}}>Update Ftw</button>
<button onclick={{action 'clearFtw'}}>Clear Ftw</button>
<button onclick={{action 'updateAdditionalParams'}}>Update Additional Params (Dynamic Json)</button>
<button onclick={{action 'clearAdditionalParams'}}>Clear Additional Params</button>
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment