Skip to content

Instantly share code, notes, and snippets.

@jherdman
Last active August 22, 2019 18:56
Show Gist options
  • Save jherdman/bc452ffbe3f718ce4d9a2c7f42a851f5 to your computer and use it in GitHub Desktop.
Save jherdman/bc452ffbe3f718ce4d9a2c7f42a851f5 to your computer and use it in GitHub Desktop.
strange-else-problem
import Controller from '@ember/controller';
import { equal, gt } from '@ember/object/computed';
export default Controller.extend({
init() {
this._super(...arguments);
this.cars = [];
this.set('counter', 0);
},
isNotReady: equal('counter', 0),
isReady: equal('counter', 1),
actions: {
makeReady() {
let { counter } = this;
this.set('counter', counter + 1);
console.log('counter before:', counter, '; counter after:', counter + 1);
}
}
});
{{#each cars as |car|}}
<p>Car!</p>
{{else}}
<p>
{{#if isNotReady}}
I'm not ready
{{else if isReady}}
I'm ready
{{else}}
I'm beyond ready
{{/if}}
</p>
{{/each}}
<button {{action "makeReady"}} type="button">
Click to make ready
</button>
{
"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