5

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.

            <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..

1 Answer 1

6

Try

tabindex="{{item.index}}"

Or even better

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

You also can access $index from ngRepeat

Sign up to request clarification or add additional context in comments.

7 Comments

Would i attach this to the li tags? I tried the first one earlier and it didnt let me tab through ` <li ng-repeat="myObj in group.myObj" ng-attr-tabindex="{{myObj.index}}"> <a ng-click="function(myObj.query)">{{myObj.name}}</a> </li>`
You add it to the element you want to add tabindex to. You don't seen to have "item.index" in your scope, this should work with a valid variable
I got {{$index}} to work instead. I'm confused why the other way didn't work though. Is there a way to select these tags by their tabindex?
I really don't understand what you are trying to do
Each of these li tags has a name. Let's say when the tab is on top of any of the li tags, I wanted to console.log or alert the {{myObj.name}} of the li tag that is currently tabbed on when the user hits the enter tab.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.