How does the toggle work?

Maybe I’m not looking in the right places and I admit to being a semi-n00b with angular, but when I look at the documentation for the toggle directive, I don’t see anything as to how you could use it to detect the toggle value change in a controller or anything like that?

How would I detect a toggle value change?

The toggle needs to be bound your $scope. So, you can just let the Toggle actual change a scope value such as in a form. If you need to take some action based on the toggle, you can $watch its value.

Here is a very simplified example. I’m using a toggle to determine whether another section of the app should show.

<div class="item item-toggle">
    <toggle ng-model="member.parent" name="parent"></toggle>
    Is {{member.givenName}} A Parent?

<div ng-show="member.parent">

    <p>This member is a parent.</p>
1 Like

This should also help explain how to do it:

We’ll keep working to make the docs better. Thanks.

1 Like