AngularJS set initial active class

前端 未结 1 1363
难免孤独
难免孤独 2021-02-09 19:11

I\'m using Bootstrap tabs with an Angular ng-repeat.

The problem I\'m running into is that the first li and the first div.tab-pane each need an

1条回答
  •  南笙
    南笙 (楼主)
    2021-02-09 19:48

    All you have to do is put an ng-class directive on the tab and tab pane that you would like active initially. You can change the expression from $index == 0 in the ng-class directive to whatever you would like. This could use a function or variable in your scope.

    Here is a JS Fiddle showing how to do this: http://jsfiddle.net/digitalzebra/qqPZd/

    And here is the final code... notice the ng-class directives:

    {{$index + 1}}

    0 讨论(0)
提交回复
热议问题