Last active
August 14, 2019 20:41
-
-
Save EWhite613/0a1917cff72d5720d69e0382276e6722 to your computer and use it in GitHub Desktop.
Query param weird example v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
nested: { | |
foo: 'bar' | |
}, | |
queryParams: ['nested.foo'] | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const {get, set} = Ember | |
const countObj = {count: 0} | |
export default Ember.Route.extend({ | |
queryParams: { | |
'nested.foo': { | |
// By default, controller query param properties don't | |
// cause a full transition when they are changed, but | |
// rather only cause the URL to update. Setting | |
// `refreshModel` to true will cause an "in-place" | |
// transition to occur, whereby the model hooks for | |
// this route (and any child routes) will re-fire, allowing | |
// you to reload models (e.g., from the server) using the | |
// updated query param values. | |
refreshModel: true, | |
// By default, the query param URL key is the same name as | |
// the controller property name. Use `as` to specify a | |
// different URL key. | |
as: 'foobar' | |
} | |
}, | |
_optionsForQueryParam (qp) { | |
const result = get(this, `queryParams.${qp.urlKey}`) || get(this, `queryParams.${qp.prop}`) | |
if (!result) { | |
const queryParams = this.queryParams | |
return queryParams[qp.urlKey] || queryParams[qp.prop] || {} | |
} | |
return result | |
}, | |
model (params) { | |
console.log('witness', params) | |
set(countObj , 'count', countObj.count + 1) | |
return params | |
}, | |
setupController (controller, model) { | |
this._super(controller, model) | |
controller.countObj = countObj | |
} | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment