mtpultz
mtpultz

Reputation: 18248

UI-Router ui-sref-active throws error when using ui-sref params

I've got a Bootstrap navbar dropdown menu, where clicking the parent link produces the dropdown list (default behaviour). The dropdown list of the parent is built using ngRepeat from an array of navigation data, and each has a ui-router state parameter, so it looks like:

 <li class="dropdown">
    <a href class="dropdown-toggle" data-toggle="dropdown">
        Parent Link
    </a>
    <ul class="dropdown-menu" role="menu">

        <li ng-repeat="item in navCtrl.items()" 
            ui-sref-active="active">
            <a ui-sref="some.state({ paramKey: paramValue })">
                {{item.link}}
            </a>
        </li>

    </ul>
</li>

But, even though it does seem to drop the active class on my link it throws this error in the console:

TypeError: Cannot read property 'name' of undefined

Upvotes: 0

Views: 622

Answers (1)

Dr G.
Dr G.

Reputation: 1332

I am not entirely sure about the answer, but, as far as I know, why would you use navCtrl.items() using brackets? I have never seen it used like that before. Wouldn't the old item in items ng-repeat work? Sorry if it does not help at all.

Upvotes: 1

Related Questions