How can I ensure that the first static tab in the second menu is always selected based on the user's selection from the first tab?

I have two tabs menus, the first one is created dynamically and the second one has a static first tab with other tabs created dynamically using ng repeat. My question is how to make the first static tab in the second menu selected no matter what the user selects from the first tabs? I tried setting 'active' but it's still not working correctly.

HTML


<tabset>
    <tab ng-repeat="tab in countytabs" heading="{{tab.countyName}}" select="selectAllUserByCounty(tab.countyID)">
        <h3>{{tab.countyName}} -- {{tab.phoneNumber}} </h3>
        <tabset>
            <tab heading="All" active="active.all" select="selectAllUserByCounty(tab.countyID)">
                <br />
                <span>Total:{{totalStatusforByCounty.total}}, In:{{totalStatusforByCounty.in}}, Out:{{totalStatusforByCounty.out}}, Unknown: {{totalStatusforByCounty.unknown}} at {{totalStatusforByCounty.lastUpdatedDateTime | date:"MM/dd/yyyy 'at' h:mma"}} </span>
                <br />
                <div ng-repeat="groupUsers in allUserByCounty">
                    <h6>
                        <b>{{groupUsers.title}}</b>
                    </h6>
                    <table ng-repeat="user in groupUsers.users">
                        <tr>
                            <td>{{user.firstName}} {{user.lastName}} Ext:{{user.voiceMailExt}} </td>
                        </tr>
                    </table>
                </div>
            </tab>
            <tab ng-repeat="departmentGroup in departmentGroups" heading="{{departmentGroup.name}}" select="selectAllUserByCountyAndDepartmentGroup(tab.countyID,departmentGroup.id)">
                {{departmentGroup.name}}<br />
                {{tab.countyID}}<br />
                {{departmentGroup.id}}<br />

                <div>
                    <p>
                        <span>
                            Total:{{totalStatusforByCountyAndDepartmentGroup.total}}, In:{{totalStatusforByCountyAndDepartmentGroup.in}}, Out:{{totalStatusforByCountyAndDepartmentGroup.out}}, Unknown: {{totalStatusforByCountyAndDepartmentGroup.unknown}} at {{totalStatusforByCountyAndDepartmentGroup.lastUpdatedDateTime | date:"MM/dd/yyyy 'at' h:mma"}}
                        </span>
                    </p>
                </div>

                <div ng-repeat="groupUsers in allUserByCountyAndDepartmentGroup">
                    <h6>
                        <b>{{groupUsers.title}}</b>
                    </h6>
                    <table ng-repeat="user in groupUsers.users">
                        <tr>
                            <td>{{user.firstName}} {{user.lastName}} Ext:{{user.voiceMailExt}} </td>
                        </tr>
                    </table>
                </div>
            </tab>
        </tabset>
    </tab>
</tabset>

My Controller

(function(){
    'use strict';

    var app = angular.module('usersboard');

    var ReceptionController = function($scope, ReceptionService){

        $scope.countytabs = '';
        $scope.totalStatusforAllCounties ='';
        $scope.totalStatusforByCounty = '';
        $scope.departmentGroups = '';
        $scope.totalStatusforByCountyAndDepartmentGroup = '';
        $scope.allUserByCountyAndDepartmentGroup = '';
        $scope.allUserByCounty = '';
        $scope.AllUserInAllDepartmentGroupsGroupByCounties = '';
        $scope.AllUsersInDepartmentGroup= '';
        $scope.active = {
            all: false
        };
        $scope.content = 'county';
        $scope.isShown = function (content) {
            return content === $scope.content;
        };

        var selectAllCounties = function(){
            ReceptionService.selectAllCounties().then(function(data){
                $scope.countytabs = data;

            }, function(errMsg){
                console.log(errMsg);
            });
        }
        selectAllCounties();

        var selectTotalStatusforAllCounties = function(){
            ReceptionService.selectTotalStatusforAllCounties().then(function(data){
                $scope.totalStatusforAllCounties = data;
                console.log(data);
            }, function(errMsg){
                console.log(errMsg);
            });
        }
        selectTotalStatusforAllCounties();

        var selectAllDepartmentGroups = function(){
            ReceptionService.selectAllDepartmentGroups().then(function (data) {
                $scope.departmentGroups = data;
                console.log(data);
            }, function (errMsg) {
                console.log(errMsg);
            });
        }
        selectAllDepartmentGroups();

        $scope.selectTotalStatusforByCounty = function (id) {
            if (typeof id !== 'undefined'){
                ReceptionService.selectTotalStatusforByCounty(id).then(function (data) {
                    $scope.totalStatusforByCounty = data;
                    console.log($scope.totalStatusforByCounty);
                }, function (errMsg) {
                    console.log(errMsg);
                });
            }

        }
        $scope.selectTotalStatusforByCountyAndDepartmentGroup = function (countyId, departmentGroup) {
            ReceptionService.selectTotalStatusforByCountyAndDepartmentGroup(countyId, departmentGroup).then(function (data) {
                $scope.totalStatusforByCountyAndDepartmentGroup = data;
                console.log($scope.totalStatusforByCountyAndDepartmentGroup);
            }, function (errMsg) {
                console.log(errMsg);
            });
        }
        $scope.selectAllUserByCountyAndDepartmentGroup = function (countyId, departmentGroup){
            $scope.selectTotalStatusforByCountyAndDepartmentGroup(countyId, departmentGroup);
            ReceptionService.selectAllUserByCountyAndDepartmentGroup(countyId, departmentGroup).then(function (data) {
                $scope.allUserByCountyAndDepartmentGroup = data;

            }, function (errMsg) {
                console.log(errMsg);
            });
        }
        $scope.selectAllUserByCounty = function (countyId) {

                $scope.selectTotalStatusforByCounty(countyId);
                ReceptionService.selectAllUserByCounty(countyId).then(function(data){
                    $scope.allUserByCounty = data;


                }, function(errMsg){
                    console.log(errMsg);
                });

        }

        $scope.selectAllUserInAllDepartmentGroups = function () {

            ReceptionService.selectAllUserInAllDepartmentGroups().then(function (data) {
                $scope.AllUserInAllDepartmentGroupsGroupByCounties = data;

            }, function (errMsg) {
                console.log(errMsg);
            });
        }
        $scope.selectAllUsersInDepartmentGroups = function (departmentGroupId) {

            ReceptionService.selectAllUsersInDepartmentGroup(departmentGroupId).then(function (data) {
                $scope.AllUsersInDepartmentGroup = data;

            }, function (errMsg) {
                console.log(errMsg);
            });
        }


    };

    app.controller('ReceptionController', ['$scope', 'ReceptionService', '$window', ReceptionController]);

}());

Answer №1

Whenever the main tab is selected, a variable (in this case, tab.activate1) is assigned a value of true. This value is then utilized to activate the initial child tab:

<tabset>
<tab ng-repeat="tab in countytabs" ng-click="tab.activate1 = true" heading="{{tab.countyName}}">
  <h3>{{tab.countyName}} - {{tab.phoneNumber}} </h3>
  <tabset>
    <tab heading="All" active="tab.activate1"></tab>
    <tab heading="Detail 1"></tab>
    <tab heading="Detail 2"></tab>
  </tabset>
</tab>
</tabset>

For a demonstration, you can access it here: http://plnkr.co/edit/Wcs2hdVtem5b2gzbCy5L?p=preview

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Displaying Child Component in Parent Component After Click Event on Another Child Component: How to Implement Angular Parent/Children Click Events

After delving into Angular 7 for a few weeks, I find myself faced with the challenge of toggling the visibility of a child component called <app-child-2> within a Parent component named <parent>. This toggle action needs to be triggered by a cl ...

I am trying to collapse the table header but I am having trouble doing so

@import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100); @import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100); body { bac ...

Storing Code into mongoDB with the Help of CasperJS

What is the best way to save data scraped using casperjs into MongoDB? My casperjs script scrapes information from millions of websites and saves each site's content in its own folder. However, I have come to realize that it would be more efficient to ...

Tips for creating CSS styles for images when hovering over them

I have been attempting to create a CSS style for an image within a div, but it does not seem to be working correctly. Below is my sample code: <div id="{{$index + 1}}" class="DeviceImages" droppable > <p class="backgroundText"> ...

What could be causing my Three.js code to fail during testing?

Recently, I decided to delve into the world of Three.js by following a thorough tutorial. While everything seemed perfectly fine in my code editor of choice (Visual Studio Code 2019), I encountered a frustrating issue when I attempted to run the code and n ...

Ways to retrieve the value of each parent element within a nested array of objects

I have a complex array of objects where each object may contain nested children. For example: const data = [ { id: 1, name: 'parent 1', children: [ { id: 'c1', nam ...

Error SCRIPT438: Property or method not supported by object in Internet Explorer

Within my application, there is an option for users to deactivate their profiles, which can only be reactivated by the admin. I have created a class called ActivateProfile with two methods: userExist(userName) to check if a user with the given userName ...

Having an issue with Angular's $http post method not returning the expected JSON

After successfully executing Recipes/CreateRecipe, the return Json is not providing any data and instead proceeds to the next function, triggering the alert message Error CreateRecipe null script $scope.createRecipe = function (recipe) { $http({ met ...

the slider HTML control is missing a value

Exploring the Range Input Type in HTML When adjusting the value on a slider (Range input type), that value is displayed in a textbox. However, making the same adjustment in the textbox does not update the slider's value. Below is the code snippet: & ...

Finding common elements between two arrays through partial matching

Imagine I have two arrays: var array_full = ['table', 'sleeping', 'data']; var array_part = ['sleep', 'able']; My goal is to extract items from the full string array (array_full) that do not contain any e ...

Integrate an input field with a copy function similar to the GitHub clone view

Can anyone help me create a view with a tooltip similar to the one on Github? You can see the example here: https://i.sstatic.net/iBSof.png I attempted to use CSS but couldn't quite replicate the exact UI. Here is my current CSS code: [tooltip] { ...

Is the javascript function I created not recognized as "a function"?

A small .js file containing 3 functions for easy in-site cookie management was created. Below is the source code: // Create Cookie function Bake(name,value) { var oDate = new Date(); oDate.setYear(oDate.getFullYear()+1); var oCookie = encodeURIComponent(n ...

HTML code now launches in the existing electron window rather than opening a new window

<html> <head> <title></title> </head> <input type="button" name="new" id="newmon" value="new"> <button onclick="open1()">monitor 1</button&g ...

The callback function was called twice after making a POST request

I am encountering an issue with my TypeScript code for processing Spotify's login flow. The code snippet is structured as follows: import * as React from 'react'; import '@patternfly/react-core/dist/styles/base.css'; import { useNa ...

Extract the sub-element within a parent element using Vue event handling

Objective The main aim is to add a class to the dropdown element .menu-item-dropdown whenever the user clicks on the .menu-item element. Issue Currently, when clicking on the .menu-item element, the returned value from the console.log inside the showMob ...

Having trouble retrieving information from req.body when trying to update product data in a MERN project

After several attempts to update a product on my ecommerce website, I encountered an issue where clicking the update button did not display any errors. Instead, it showed the old data and failed to make changes in the MongoDB database. Even when testing in ...

information provided by the service in JSON format

I am trying to make a service call: $http({ method: 'GET', url: '/api/html?conditionId=123&TypeId=100&countryId=1' }).success(function (data) { var obj = JSON.parse(data); alert(obj.ConditionId); ...

Concealing a button in Vue.js and Laravel effortlessly

I am struggling to figure out how to hide the button when there is no data in the table in my Vue.js project. Since I am new to Vue.js, I would really appreciate any help or guidance on how to achieve this. If there is another way to accomplish this, pleas ...

Locate a particular text and enhance it with bold styling by utilizing JavaScript or jQuery

I am searching for a specific string within a webpage, such as the word "ibf". This string could be located in any element of text on the page without a designated class. There may even be multiple elements containing the string. Here is an example snippe ...

Transitioning Web Application to Angular Version 2

I am currently in the process of transitioning a web application to Angular2. I have successfully transferred the HTML and CSS files to Angular's component.html and component.css respectively. However, I am encountering some difficulties with the .js ...