Skip to main content

Toggle Attribute

About

The $toggle directive is used to conditionally show or hide content based on a boolean value.

Usage

~index.html
<div $toggle="isVisible">
This content will be toggled.
</div>

How it Works

  • The framework observes the specified boolean value.
  • When the value is true, the content is shown.
  • When the value is false, the content is hidden.
  • The framework automatically updates the visibility when the boolean value changes.

Error Handling

If the specified boolean value is not found or is invalid, the element might remain in its default state. Errors are typically logged to the console.

Note

note

The $toggle directive provides a simple way to control the visibility of elements without removing them from the DOM, which can be useful for performance in frequently toggled content.