Sharing Top Content from the Angular-sphere.

[Solved-Answers]Set active tab style with AngularJS –

[Solved-Answers]Set active tab style with AngularJS -

  • when(‘/lab’, {templateUrl:’partials/lab’, have some links on the topbar styled as tabs.
  • How can you add ‘active’ class to a tab depending on current template or url?
  • 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

    SOLUTION 2 way of doing this would be by using ngClass directive and the $location service.

  • In your template you could do:
    where isActive would be a function in a scope defined like function($scope, $location) {
    $scope.isActive = function(route) {
    return route === $location.path();
    each navigation tab might be tedious (if you’ve got many tabs) so this logic might be a candidate for a very simple directive.

Set active tab style with AngularJS – JavaScript – You have some links on the topbar styled as tabs. How can you add ‘active’ class to a tab depending

@WikitechyCom: [Solved-Answers]Set active tab style with AngularJS –

You have routes set in AngularJS like this:

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

SOLUTION 1 :

 configuration, like this:

 in your controller:

 class based on the current active tab:

  • SOLUTION 2 :

    One way of doing this would be by using ngClass directive and the $location service. In your template you could do:

     would be a function in a scope defined like this:

     on each navigation tab might be tedious (if you’ve got many tabs) so this logic might be a candidate for a very simple directive.

    Tags: angular 2 ng class, angular material tabs, angular ng class, angular tabs, angularjs ng class, angularjs tabs, angularjs tabs example, bootstrap horizontal menu, bootstrap horizontal tabs, bootstrap left menu, bootstrap nav tabs, bootstrap pills, bootstrap pull right, bootstrap responsive tabs example, bootstrap tab panel, bootstrap tab styles, bootstrap tabs, bootstrap tabs demo, bootstrap tabs design, bootstrap tabs example, bootstrap tabs responsive, bootstrap ul, bootstrap vertical tabs, bootstrap vertical tabs responsive, div tag, href in angularjs, javascript codes, javascript download, javascript examples, javascript pdf, javascript tabs, javascript tutorial point, javascript w3schools, javascript wiki, nav pills, nav tabs, nav tabs bootstrap, ng bootstrap, ng class angular 2, ng class angularjs, ng class example, ng class in angularjs, responsive tabs bootstrap, tab css, tab pane, tabpanel, tabs bootstrap, tabs in angularjs, tabs in bootstrap, tabul, vertical tabs bootstrap, vertical tabs in bootstrap

    [Solved

    Comments are closed, but trackbacks and pingbacks are open.