As shown in the picture, the above 5 blocks are output in a loop using ng-repeat. How to realize that when a certain block (such as block 2) is clicked, the background of the block Color changes to red? The colors of other blocks remain unchanged.
Thanks for the advice.
There are too many methods, ng-click, ng-class, directive can be implemented.
This is a direct method, for reference only
html:
js
Add click event. Pass the $index and $event of the current loop. Then it's OK to handle it yourself through angular jq.
Give you a ready-made code:
HTML
JS
CSS
I am planning to write a directive to do this
http://runjs.cn/detail/yfnwk6ho