What is the best way to use AngularJS to distinguish tab headings from their corresponding content sections?

Currently, I am working on an angularjs project where I am using the uib-tabset directive to display tabs. My goal is to have a left panel that remains consistent across all tabs. This requires me to insert a div either before or after the uib-tabset directive.

By default, the headings are placed directly above the tab bodies. https://i.sstatic.net/Efjms.jpg

Visually, I would like to integrate the panel inside each tab in the generated structure: https://i.sstatic.net/emZQC.jpg

When utilizing uib-tabsets, the structure typically looks like this:

<panel>
<tabs-headings>
<tabs-bodies>

My current approaches involve manipulating the CSS to adjust the positioning of the headings relative to the side panel, which I consider risky, or duplicating the panel code within each tab, which feels inefficient.

Instead, my preferred structure would be as follows for easier CSS creation:

<tabs-heading>
<panel>
<tabs-bodies>

Is there a straightforward method to achieve this desired behavior?

Thank you

Answer №1

Update: Haha, just realized I'm a whole 10 months behind.

I recently came across the issue you're discussing. If you're dynamically rendering content in each tab using ng-repeat, it can help avoid constantly recreating the side panel.

<div class="tabWrapper">
    <uib-tabset>
        <uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">

            <div class="sidePanel">{{tab.sidepanel}}</div> 
            <div class="tabContent">{{tab.content}}</div>

        </uib-tab>
    </uib-tabset>
</div>

You won't have to deal with absolute positioning either:

.sidePanel {
    float: left;
    width: 20%;
    height: 10em;
    border: 1px solid black;
    border-top: none;
}

Alternatively, if you're utilizing angular-ui-router, you could achieve the static side panel by using abstract states.

config.js

$stateProvider
    .state('root.tabs', {
        abstract: true,
        controller: 'TabsCtrl as vm',
        templateUrl: 'templates/app-layout/tabs.tpl.html'
    })   
    .state('root.tabs.view', {
        url: '/tabsview',
        templateUrl: 'templates/app-layout/sidepanel.tpl.html'
    });

tabs.tpl.html

<div>
    <uib-tabset>
        <uib-tab index="$index + 1" ng-repeat="tab in tabs" heading="{{tab.title}}" disable="tab.disabled">

            <div class="sidePanelContainer" ui-view></div>

            <div class="tabContent">{{tab.content}}</div>
        </uib-tab>
    </uib-tabset>
</div>

sidepanel.tpl.html

<div class="sidePanel">
    <input type="text" value="1234">
    <input type="text" value="4321">
</div>

Check out this link too: what is the purpose of use abstract state?

Hope this information proves useful!

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

Ensure that the AngularJS ng-repeat filter is applied to all the data, including the unfiltered

Hello there, I am a newcomer to angularjs and have a question that has been puzzling me. Let's take a look at my ng-repeat code below: <ul ng-repeat="todo in filteredData | filter:search"> It appears that this code only filters the filteredDa ...

Newbie problem with css - Struggling to position link in top right corner

I want to have a link appear on the top right corner that opens a new tab with another page. Although the tab and page open correctly, the link remains stuck in the top left corner. Despite trying various solutions from Stackoverflow, nothing seems to be ...

Challenges with Internal Styling on Wordpress Sites

Okay. I've been dealing with some internal style issues on my Wordpress website. After dedicating hours to trying to change styles for various elements, I realized that the main html file contained a bunch of internal style sheets that were overridin ...

Creating dynamic dropdown menus with AngularJS, PHP, and MySQL: A Comprehensive Guide

How can I dynamically generate and select items from a dropdown menu based on data stored in a MySQL database using AngularJS, PHP, and HTML? I have already implemented code to retrieve and display items from a database in a grid format, but I need help in ...

Include an Open OnClick event in the React/JSX script

We have a dynamic menu created using JavaScript (React/JSX) that opens on hover due to styling. My inquiries are: Instead of relying on CSS for the hover effect, where in the code can I implement an OnClick event to trigger the menu opening using Java ...

Potential drawbacks of employing front-end frameworks for managing APIs include concerns related to efficiency and data protection

As I delve into learning various new technologies such as Angular 2, AngularJS, Firebase, Loopback, NodeJS etc., I find myself encountering some lesser-discussed topics that leave me feeling confused. While exploring these technologies, certain aspects cat ...

Nodejs server is not able to intercept tokens when utilizing the Facebook authentication strategy with AngularJS

I am currently learning nodejs/angularjs and developing my first basic web application. I have implemented Facebook authentication strategy using Passport and Node.js. Upon successful authentication, I want to send a jwt token back to the Angular client ap ...

Encourage UL to expand along with its contents, specifically the inline block list items

Struggling to get list items in a css menu to float left without setting the width of the parent UL. You can check out my progress on this JS fiddle: http://jsfiddle.net/FkK7Y/1/ In the "products menu," I have two sets of links that are currently stackin ...

Removing the dollar sign and retaining only the numerical values in an array using JavaScript

Using the code snippet below, I am attempting to retrieve elements by their class name in JavaScript and save them in an array. This is the current output I receive: "I received this output from the initial prices array $30.00, $20.00, $40.00" My inquiry ...

Create a dynamic animation effect for the placeholder in an input field that triggers when the user starts typing

Have you ever come across interactive demos like this one? I've noticed that most examples involve creating a new element. parent().append("<span>" + $input.attr('placeholder') + "</span>"); Is there a way to make the placehol ...

I am perplexed by JQuery. It is returning true when comparing an input value from a number type input, and I cannot figure out the reason behind it

Seeking guidance on a perplexing issue. Here is a basic code snippet to depict my dilemma: html: <form> <input type="number" id="someNumber"> <input type="button" id="submitBtn"> </form> jquery: $("#submitBtn"). ...

What is the correct way to add "itemCondition" and "logo" schema tags to schema.org product snippets?

I'm in the process of enhancing my product page with schema.org snippets. My client has specifically requested the inclusion of certain schema.org tags on the product's individual page. 1) itemCondition 2) logo (displaying only the brand image ...

ways to dynamically retrieve input values in PHP

Is there a way to dynamically add and remove data fields, as well as increase and decrease fields dynamically in PHP? I am looking to retrieve the subject value in an array or JSON format using PHP only. https://i.stack.imgur.com/HqDCz.png <div data-ro ...

The HTMLEditor from ASP.NET AJAX Control Toolkit is not appearing correctly on the page

My experience with the ASP.NET AJAX Control Toolkit HTMLEditor has been less than satisfactory. The toolbar layout is not being displayed correctly, with what should be a 3-line toolbar appearing stretched out to 9 lines. ...

Creating a mobile application on both Android and iOS platforms can be an exciting project. By leveraging an existing

Looking to create an Android and iOS application using an existing ASP.net console application. Below is the folder structure of my project, which is developed with ASP.net and Angular 4. The startup project in my project is app.ColorSelector, which includ ...

The collapsible navigation bar in Bootstrap

I'm having issues with my Bootstrap collapsible menu. Can someone help me identify the problem? <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <a class= ...

What are the steps to design a curved trapezoid using CSS?

Is it possible to achieve this using CSS? This is the current progress I've made: div { -webkit-clip-path: polygon(0 79%, 60% 78%, 78% 100%, 0 100%); clip-path: polygon(0 79%, 60% 78%, 78% 100%, 0 100%); background:red; height:300px; ...

Adding a border to the <area> element: A step-by-step guide

Can a border be added around an <area> element? This would be useful for testing an imagemap, however the following code does not achieve the desired effect: area { outline: 1px solid red; border: 1px solid red; } ...

Struggling with iterating over an Angular array?

I am attempting to iterate through this array. However, I am not seeing anything inside the {{repeat.title}} I am iterating through the array using the following HTML/Angular code: <div class="column inline inline-4 center choice" ng-repeat="repeat i ...

Uncertainty Surrounding the Functionality of Javascript's 'then' Method

Within my Angular controller, I have the following code snippet... function performTask() { // Display the loading modal $scope.modal = $ionicLoading.show({ content: 'Fetching current location...', showBackdrop: false }); consol ...