0

In my application, I am getting this same error (TypeError: "Cannot read property 'activeMenuTab' of undefined") 3 times on browser console, although application is working very well.

Error refers to this line of code in controller:

$scope.$route = $route;
$scope.isSelected = function(menuTab) {
    return $route.current.activeMenuTab == menuTab;
};

I call this function from menu in View:

<ul>
<li><a href="#somePage" ng-class="{ active: isSelected('somePage') }">...</a></li>
.
.
.
</ul>

Does anybody know what to do with this error, please? I try my best to solve it, but as I can see, still not enough.

PeterCZ
  • 27
  • 1
  • 5

1 Answers1

0

The error tell you that $route.current is undefined, so it canot access the property 'activeMenuTab'. You need to save in your controller scope "activeMenuTab".

Maybe you can take a look at this How to highlight a current menu item?

for a better way?

Community
  • 1
  • 1
Yahel
  • 546
  • 5
  • 6