Skip to content

Instantly share code, notes, and snippets.

@MichalBryxi
Last active June 22, 2021 11:26
Show Gist options
  • Save MichalBryxi/2ac71f390400270576243dd8f4ffb996 to your computer and use it in GitHub Desktop.
Save MichalBryxi/2ac71f390400270576243dd8f4ffb996 to your computer and use it in GitHub Desktop.
currentPage
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { computed } from '@ember/object';
export default Controller.extend({
// currentPage = 0;
_data: 0,
currentPage: computed({
get() {
console.log("get() ", this._data);
return this.get('_data');
},
set(k, value) {
console.log("set() ", this._data, {k}, {value});
this.set('_data', value);
return value;
}
}),
actions: {
increment() {
console.log(this.get('currentPage'));
this.set('currentPage', this.get('currentPage') + 1);
}
}
});
Current page is: {{this.currentPage}}
<button type="button" {{action "increment"}}>
Increment
</button>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-data": "3.18.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment