Created
February 12, 2019 20:24
-
-
Save sukima/94708c3c5c98d451bf8bf7b9b9e7e1b7 to your computer and use it in GitHub Desktop.
Serialize objects in QP
This file contains 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 Controller from '@ember/controller'; | |
import { reads } from '@ember/object/computed'; | |
export default Controller.extend({ | |
queryParams: ['theObject'], | |
actions: { | |
updateTheObject() { | |
this.set('theObject', { appName: this.appName }); | |
} | |
} | |
}); |
This file contains 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 Route from '@ember/routing/route'; | |
export default Route.extend({ | |
queryParams: { | |
theObject: { type: 'object' } | |
}, | |
setupController(controller) { | |
this._super(...arguments); | |
controller.set('appName', 'Test'); | |
}, | |
serializeQueryParam(value, key, type) { | |
if (type !== 'object') return this._super(...arguments); | |
return JSON.stringify(value); | |
}, | |
deserializeQueryParam(value, key, type) { | |
if (type !== 'object') return this._super(...arguments); | |
return JSON.parse(value); | |
} | |
}); |
This file contains 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