Skip to content

Instantly share code, notes, and snippets.

@Sinled
Forked from arturkot/components.my-component.js
Created September 7, 2016 12:33
Show Gist options
  • Save Sinled/5a7345d57cd9112ab8b3fd307d7ad45a to your computer and use it in GitHub Desktop.
Save Sinled/5a7345d57cd9112ab8b3fd307d7ad45a to your computer and use it in GitHub Desktop.
Query Params test
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setArray () {
this.set('array', [4, 5]);
this.sendAction('performTransition');
},
setNumber () {
this.set('number', 3);
this.sendAction('performTransition');
},
setBoolean () {
this.set('boolean', false);
this.sendAction('performTransition');
},
setAll () {
this.set('array', [4, 5]);
this.set('number', 3);
this.set('boolean', false);
this.sendAction('performTransition');
},
resetQueryParams () {
this.set('array', []);
this.set('number', null);
this.set('boolean', null);
this.sendAction('performTransition');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: ['array', 'number', 'boolean'],
array: [],
number: null,
boolean: null,
typeOfArray: Ember.computed('array', function () {
return Ember.typeOf( this.get('array') );
}),
typeOfNumber: Ember.computed('number', function () {
return Ember.typeOf( this.get('number') );
}),
typeOfBoolean: Ember.computed('boolean', function () {
return Ember.typeOf( this.get('boolean') );
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('my-route');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend();
import Ember from 'ember';
export default Ember.Route.extend({
controllerName: 'application',
actions: {
performTransition () {
this.transitionTo('application');
}
}
});
<h1>Welcome to {{appName}}</h1>
<ul>
<li>{{typeOfArray}}</li>
<li>{{typeOfNumber}}</li>
<li>{{typeOfBoolean}}</li>
</ul>
{{#link-to "my-route"}}My Route!{{/link-to}}
<br>
<br>
{{outlet}}
<br>
<br>
<button {{action "setArray"}}>Set array</button>
<button {{action "setNumber"}}>Set number</button>
<button {{action "setBoolean"}}>Set boolean</button>
<button {{action "setAll"}}>Set All</button>
<button {{action "resetQueryParams"}}>Reset Params</button>
{{my-component array=array boolean=boolean number=number performTransition="performTransition"}}
{
"version": "0.8.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.4.5",
"ember-data": "2.4.3",
"ember-template-compiler": "2.4.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment