Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: ui-sref-active with nested states broken in 0.2.11 but not 0.2.10 #1314

Closed
kz26 opened this issue Aug 30, 2014 · 6 comments · Fixed by #1361
Closed

Regression: ui-sref-active with nested states broken in 0.2.11 but not 0.2.10 #1314

kz26 opened this issue Aug 30, 2014 · 6 comments · Fixed by #1361
Assignees
Labels
Milestone

Comments

@kz26
Copy link
Contributor

kz26 commented Aug 30, 2014

Loading a template for a parent state throws the following error in 0.2.11 but not 0.2.10 due to ui-sref-active. This error seems to be non-fatal as everything still seems to work. Changing to ui-sref-active-eq fixes the error.

Chrome console traceback:

TypeError: Cannot read property 'name' of undefined
    at isMatch (http://angular-ui.github.io/ui-router/release/angular-ui-router.js:3606:39)
    at update (http://angular-ui.github.io/ui-router/release/angular-ui-router.js:3595:13)
    at Scope.$broadcast (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:12952:28)
    at $state.transition.resolved.then.$state.transition (http://angular-ui.github.io/ui-router/release/angular-ui-router.js:2662:22)
    at wrappedCallback (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:11561:81)
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:11647:26
    at Scope.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:12673:28)
    at Scope.$digest (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:12485:31)
    at Scope.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:12777:24)
    at done (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js:8371:45) angular.js:10061

State definition:

$stateProvider
    .state 'myProfile', {
        url: '/myProfile'
        controller: 'MyProfileCtrl'
        templateUrl: 'index.html'
        abstract: true
    }
    .state 'myProfile.basicInfo', {
        url: '/basicInfo'
        templateUrl: 'basicInfo.html'
    }

index.html:

<ul>
    <li ui-sref-active="active"><a ui-sref="myProfile.basicInfo">Basic Info</a></li>
    <li ui-sref-active="active"><a ui-sref="myProfile.aboutMe">About Me</a></li>
</ul>
@kz26
Copy link
Contributor Author

kz26 commented Sep 1, 2014

Managed to track down the cause of this issue. I had a placeholder link where I had a ui-sref-active attribute but no ui-sref. Nevertheless, for the sake of consistency between the ui-sref-active and ui-sref-active-eq directives, it's probably a good idea to check if state is actually defined in isMatch().

@plumpNation
Copy link

Ahaaaa! Thanks @kz26 for that. It's been bugging the hell out of me for a while now. Good work :)

👍

@RobiFerentz
Copy link

Thanks @kz26 that saved me some time. I agree with you about the consistency thing.

@tamtakoe
Copy link

👍

@yasar
Copy link

yasar commented Oct 20, 2014

ui-sref-active-eq fixed my case, too. thanks.

@SISSIYAM
Copy link

ui-sref-active-eq workd for me,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants