changing div class when child checkbox is checked

1,791 views
Skip to first unread message

Xavier MARTIN

unread,
Jan 31, 2013, 10:24:13 PM1/31/13
to ang...@googlegroups.com
Hello everyone,

I have the following code

<div ng-controller="controllerLibrary">
    <ul class="module_list">
        <li ng-repeat="module in modules">
            <div class="span4 module_card">
               <input id="{{module.title}}" type="checkbox" class="custom_checkbox"><label class="title" for="{{module.title}}">{{module.title}}</label>
                <p>{{module.description}}</p>
                <p><a class="btn btn_addlearning" ng-class="getCardButtonClass(module)" ng-click="addToMyLearning(module)">{{createButtonText(module)}}</a></p>
            </div>
        </li>
    </ul>
</div>

and I would like to be able to update the css class of the div highlighted in orange (ie div class="span4 module_card") when its child checkbox is checked.
I have looked into the ng-class and angular expression.
My two questions would be:
- if you can actually access an html element and attribute from inside the angular expression.
- what would be the best approach to do this.

Thanks a lot for any help you could provide,
Cheers,
Xavier

Peter Bacon Darwin

unread,
Feb 1, 2013, 8:29:13 AM2/1/13
to ang...@googlegroups.com
In AngularJS, you need to work with the scope rather than thinking about the DOM.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Xavier MARTIN

unread,
Feb 3, 2013, 5:46:16 PM2/3/13
to ang...@googlegroups.com
Wow, this one got under the radar.
Thank you very much for your answer and advice.

Cheers,
Xavier
Reply all
Reply to author
Forward
0 new messages