I figured out the culprit but I still don't know how to fix the code to
make it work in ui-router.
I ran the application using ngRoute and the $location.path had a value of
'/demo/Pie3d'. I was debugging it inside Chrome Dev Tools. The working code
is
$scope.navClass = function (page) {
var routeMatch = $location.path().match(/\/(\w+)\//);
$scope.currentRoute = routeMatch && routeMatch[1] || 'demo';
return page === $scope.currentRoute ? 'active' : '';
};
I converted this code and hoping my code will work in ui-router. However
$state.go() was failing with TypeError: Cannot read property 'name' of
undefined
The new code is below but is failing
$scope.navClass = function (page) {
var routeMatch = $state.go().match(/\/(\w+)\//); // <--- This is where
it's failing.
$scope.currentRoute = routeMatch && routeMatch[1] || 'demo';
return page === $scope.currentRoute ? 'active' : '';
};
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.