Angular Js : How to find first and last element in ng-repeat and add special class to them?

后端 未结 2 778
灰色年华
灰色年华 2021-02-18 14:18

I changed the following using angular js

Social Profiles

相关标签:
2条回答
  • 2021-02-18 14:34

    Just use $first and $last combined with ng-class:

    <a ng-repeat="sMedia in socialMedia" ng-class="{'first': $first, 'last': $last}" href="#" >
    

    See here how they work: https://docs.angularjs.org/api/ng/directive/ngRepeat

    0 讨论(0)
  • 2021-02-18 14:42

    You can use:

    #social a:first-child{ /* your first css code */ }
    #social a:last-child{ /* your last css code */ }
    
    0 讨论(0)
提交回复
热议问题