Question: I use ng-repeat to loop out the data. How do I do this: 1. When opening the page, does the first li displayed by default have a style? 2. Does the currently clicked li have styles, while other li's have no styles?
The following is the html code diagram:
<ul ng-repeat="u in pinpaiData" class="product_box">
<li ng-repeat="c in u.goods" class="defaultClass" ng-click="twoClick($index)" >{{c.goods_name}}</li>
</ul>
Use ng-class to create a chosenIndex variable in $scope to store the index of the currently selected li. The default is 0. Assume that the selected class is called chosenClass.