有条件地申请课程的最佳方式是什么?
问题: Lets say you have an array that is rendered in a ul with an li for each element and a property on the controller called selectedIndex . 假设你有一个在 ul 呈现的数组,每个元素都有一个 li ,而控制器上的一个属性叫做 selectedIndex 。 What would be the best way to add a class to the li with the index selectedIndex in AngularJS? 什么是一类添加到最好的办法 li 与指数 selectedIndex 在AngularJS? I am currently duplicating (by hand) the li code and adding the class to one of the li tags and using ng-show and ng-hide to show only one li per index. 我目前正在复制(手动) li 代码并将类添加到其中一个 li 标签中,并使用 ng-show 和 ng-hide 仅显示每个索引一个 li 。 解决方案: 参考一: https://stackoom.com