#94 Toggle

Ever wanted to toggle a property from your template without creating an action?  Of course you did.

I wrote a tip (#38 Pipe multiple actions) about the awesome ember-composoable-helpers add-on.  Using that same add-on, here is how to toggle a boolean property without writing component/controller code.

Old way:

Better way:

That’s it – no code needed.

Published by

Emad Ibrahim

Author of asp .net MVC & TDD, entrepreneur, passionate technologist, programmer and productivity nut. more at http://t.co/oSJXPvzu

  • collegeimprovements me

    This is so so cool. Thanks for sharing this tip. Please keep it up your awesome work 🙂

  • BC

    Tried the better way and I got this error:

    Uncaught Error: Assertion Failed: A helper named ‘toggle’ could not be found

    • BC

      Ah figured it out

      {{action toggleProperty ‘flag’}}

      • Did you install get the ember composable helpers? It doesn’t seem like you did.

        • BC

          oh yeah i didn’t, but guess i can toggle properties without an action handler with the method mentioned above as well.