Skip to content

Instantly share code, notes, and snippets.

@etuchscherer
Created February 28, 2018 17:09
Show Gist options
  • Save etuchscherer/8ebac8cbdd3315a1783e0803288bfb9c to your computer and use it in GitHub Desktop.
Save etuchscherer/8ebac8cbdd3315a1783e0803288bfb9c to your computer and use it in GitHub Desktop.
Hiding Components
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: true,
shouldShowComponent: Ember.computed('value', {
get() {
return this.get('value');
}
}),
actions: {
doToggle() {
console.log('foo :: ', this.get('value'));
this.toggleProperty('value');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{log shouldShowComponent}}
{{#if shouldShowComponent}}
{{conditional-component}}
{{else}}
<h2>This conditional component is hidden</h2>
<p>shhh ! don't tell anyone !</p>
{{/if}}
<br>
<br>
<button {{ action "doToggle" }}>Toggle Component</button>
<h2>Now showing the conditional-component</h2>
<p>Yeay !!! celebrate !!</p>
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment