Created
September 27, 2018 14:16
-
-
Save sukima/bc7c2dcc1be9e5e542528f2c5e1fdda0 to your computer and use it in GitHub Desktop.
Using computed properties in queryParams
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 Ember from 'ember'; | |
import moment from 'moment'; | |
const { computed } = Ember; | |
export default Ember.Controller.extend({ | |
queryParams: ['before'], | |
before: '2017-08-23T03:55:00Z', | |
beforeDate: computed('before', { | |
get() { | |
return moment(this.get('before')); | |
}, | |
set(key, value) { | |
this.set('before', value.format()); | |
return value; | |
} | |
}), | |
actions: { | |
updateExample() { | |
let strValue = this.get('exampleInput'); | |
let newDate = moment(strValue); | |
if (newDate.isValid()) { | |
this.set('beforeDate', newDate); | |
this.set('exampleInput', ''); | |
} | |
} | |
} | |
}); |
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.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"hack_css": "https://cdnjs.cloudflare.com/ajax/libs/hack/0.8.0/hack.css", | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0", | |
"ember-moment": "7.8.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment