Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:27+00:00 2026-06-11T20:47:27+00:00

I have routes set in AngularJS like this: $routeProvider .when(‘/dashboard’, {templateUrl:’partials/dashboard’, controller:widgetsController}) .when(‘/lab’, {templateUrl:’partials/lab’,

  • 0

I have routes set in AngularJS like this:

$routeProvider
    .when('/dashboard', {templateUrl:'partials/dashboard', controller:widgetsController})
    .when('/lab', {templateUrl:'partials/lab', controller:widgetsController})

I have some links on the topbar styled as tabs. How can I add ‘active’ class to a tab depending on current template or url?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:47:28+00:00Added an answer on June 11, 2026 at 8:47 pm

    A way to solve this without having to rely on URLs is to add a custom attribute to every partial during $routeProvider configuration, like this:

    $routeProvider.
        when('/dashboard', {
            templateUrl: 'partials/dashboard.html',
            controller: widgetsController,
            activetab: 'dashboard'
        }).
        when('/lab', {
            templateUrl: 'partials/lab.html',
            controller: widgetsController,
            activetab: 'lab'
        });
    

    Expose $route in your controller:

    function widgetsController($scope, $route) {
        $scope.$route = $route;
    }
    

    Set the active class based on the current active tab:

    <li ng-class="{active: $route.current.activetab == 'dashboard'}"></li>
    <li ng-class="{active: $route.current.activetab == 'lab'}"></li>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this set of routes: routes.MapRoute( IssueType, issue/{type}, new { controller = Issue,
Im having a little trouble setting up routes. I have a 'users' controller/model/views set
I have set up a controller called links, i have the routes to several
I have the following routes set up: context.MapRoute( content_article, A{rk}/{title}, new { controller =
I have two routes set up in my application: routeCollection.MapRoute(CustomerActivity, Customer/{id}, new { controller
If I have some routes set up as follows: context.MapRoute(Route1, Public/DataCapture/Name, new { controller
I have routes like this: resources :users do resources :projects end I would like
I have routes set up that look like: match '/things/:thing_id' => descriptions#index, :as =>
I'd like to have routes set up as follows: xyz/ maps to one action
I have a hairy set of routes that I'm upgrading from Rails 2 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.