javascript 向 AngularJS 手风琴添加标签索引?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24496937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 02:55:04  来源:igfitidea点击:

Adding a tab index to an AngularJS accordion?

javascriptjqueryangularjsaccordiontabbing

提问by es3735746

Hi I have an AngularJS accordion that I've created with the code below. I would like to add a tab index to the accordion such that someone can tab through all the li tags of the accordion.

嗨,我有一个 AngularJS 手风琴,我用下面的代码创建了它。我想为手风琴添加一个标签索引,以便有人可以浏览手风琴的所有 li 标签。

            <accordion close-others="showOnlyOne">
                <accordion-group heading="{{group.name}}" ng-repeat="group in reportFiltered"  is-open="group.isThisOpen">
                    <ul class="nav">
                        <li ng-repeat="myObj in group.myObj">
                            <a ng-click="function(myObj.query)">{{myObj.name}}</a>
                        </li>
                    </ul>
                </accordion-group>
            </accordion>

I have tried doing things such:

我试过做这样的事情:

tabIndex="item.index

but that doesn't seem to work.

但这似乎不起作用。

Furthermore, I also need a way to access the tabs contents/value once they are currently tabbed on...but thats my next issue.

此外,我还需要一种方法来访问选项卡的内容/值,一旦它们当前被选中……但那是我的下一个问题。

UPDATE:

更新:

I got the tabbing to work with {{$index}} but now I need to do something with the current li tag that is being tabbed over..

我得到了与 {{$index}} 一起使用的制表符,但现在我需要对当前被制表符的 li 标签做一些事情..

回答by Thomas Roch

Try

尝试

tabindex="{{item.index}}"

Or even better

或者更好

ng-attr-tabindex="{{item.index}}"

You also can access $index from ngRepeat

你也可以从 ngRepeat 访问 $index