Skip to content

Instantly share code, notes, and snippets.

@tarponjargon
Last active February 10, 2017 06:17
Show Gist options
  • Save tarponjargon/faa438ae5096bd3738c53237b1b23fde to your computer and use it in GitHub Desktop.
Save tarponjargon/faa438ae5096bd3738c53237b1b23fde to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: [
'foo'
],
foo: [],
actions: {
removeItem: function(i) {
alert(`about to remove ${i.toString()}`);
this.foo.removeObject(i.toString());
console.log(this.foo);
},
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('results');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
foo: { refreshModel: true }
}
});
<h1>query param arrays</h1>
paste this into the URL field above:<br>
<br>
/results?foo=%5B%22ray%22%2C%22freakin%22%2C%22tiley%22%5D
<br><br>
which should end up controller property:<br><br>
foo: ['ray','freakin','tiley']
{{outlet}}
<br>
<br>
<br><br>
foo array contains: {{foo}}<br><br>
Click one to remove from array:<br>
{{#each foo as |f|}}
delete <a href="#" {{action "removeItem" f}}>{{f}}</a><br>
{{/each}}
{{outlet}}
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment