Skip to content

Instantly share code, notes, and snippets.

@rileyhilliard
Created October 31, 2017 16:59
Show Gist options
  • Select an option

  • Save rileyhilliard/9718b159dd74826c62b378a5243948f8 to your computer and use it in GitHub Desktop.

Select an option

Save rileyhilliard/9718b159dd74826c62b378a5243948f8 to your computer and use it in GitHub Desktop.
Undefined equality check
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
aPropertyThatsFalsey: 'NOT_CTA_BOTTOM',
aPropertyThatsTruthy: 'CTA_BOTTOM',
init() {
this._super(...arguments);
this.setProperties({
undefinedEx: this.undefinedExample(),
falseEx: this.falseExample(),
trueEx: this.trueExample(),
});
},
undefinedExample() {
return this.get('aPropertyThatDoesntExist.thisForsureDoesntExist.andThisAbsolutlyDoesntExist') === 'CTA_BOTTOM';
},
falseExample() {
return this.get('aPropertyThatsFalsey') === 'CTA_BOTTOM';
},
trueExample() {
return this.get('aPropertyThatsTruthy') === 'CTA_BOTTOM';
},
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<ul>
<li>Undefined example: {{undefinedEx}}</li>
<li>False example: {{falseEx}}</li>
<li>True Example: {{trueEx}}</li>
</ul>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment