Tip
Submitted By: Devin Weaver (lightly edited by me)
There are times when you can perform the following with components:
1 2 3 |
{{my-component data=data shouldShow=showMyComponent action=(action (mut showMyComponent) false)}} |
But it gets more complex in a helper like so:
1 2 3 |
<a href="#" {{action "myAction"}}> Open My Component </a> |
So how do you use the same trick above and avoid creating the controller action myAction? Here is how:
1 2 3 4 5 |
<a href="#" {{action (action (mut showMyComponent) true)}}> Open My Component </a>{{my-component data=data shouldShow=showMyComponent action=(action (mut showMyComponent) false)}} |
Credits & Links
Thank you Devin for the tip – source http://snip.ly/170ur
A good explanation of {{mut}} helper at http://snip.ly/ylxan
Free Programming Books and lifetime access to IconApp.io
I am giving away some programming books and lifetime access to iconapp.io library of awesome icons. Check it out at https://gleam.io/XqHjW/rock-and-roll-with-emberjs
Share A Tip
Let us know if you have a good ember tip (you will get full credit)
If you are enjoying my daily tips please spread the word with this one-click tweet.
If you do NOT like the tips then please reply to this email and let me know how I can improve them.