Change content on click with AngularJS
If you need to change an element content, whatever it is: text or an icon, with AngularJS is super easy.
Just need to set a variable to change the condition:
#the variable (and can be the name you want)
ng-model="collapsed"
#change the condition on click :D
ng-click="collapsed=!collapsed"
And magic happens like this:
<button ng-model="collapsed" ng-click="collapsed=!collapsed">
<i ng-class="{'fa fa-angle-up':collapsed,'fa fa-angle-down':!collapsed}"></i>
</button>
Written by HelenaVI
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#