Dynamically generate angular checkbox columns

Struggling to dynamically generate columns of checkboxes in a dropdown using Angular and Bootstrap. Each checkbox item may or may not have related children.

The initial solution involved placing everything inside a div (.col-sm-4) from the Bootstrap grid system, but the items weren't aligned correctly.

Check out the code snippet below for an example:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" style="font-size:14px; padding: 16px 15px">Item Name <span class="caret"></span></a>
  <ul class="dropdown-menu" style="border:1px solid #dcdcdc;border-radius: 3px; width:1000px;">
      <li ng-repeat="result in vm.listAnuncios.anunciosAgrupadosPorTipoPeca">
          <div class="col-sm-4" style="border:1px solid red;">
            <input type="checkbox" ng-click="vm.selectAll($event)" />
              <span class="lbl padding-8" style="color:#8b8b8b; font-size:12px !important">
                {{result.name}}
                <span style="color:#b0b0b0;">{{result.total}}</span>
              </span>

              <ul id="tp_{{result.subTypeName}}">
                  <li ng-repeat="subItem in result.subItemsGrouped" style="margin-left:25px;">
                    <input type="checkbox" ng-click="vm.selectAll($event)" />
                      <span class="lbl padding-8" style="color:rgba(139, 139, 139, 0.88); font-size:12px !important">
                        {{subItem.name}}
                        <span style="color:#b0b0b0;">{{subItem.total}}</span>
                      </span>
                  </li>
              </ul>

          </div>
      </li>
  </ul>
</li>

(Please ignore any Portuguese text within the code.)

Expected Result:

View Image Here

Answer №1

Experience the power of the following code snippet. If you require any modifications, please provide me with the complete code along with the data.

Check out the FIDDLE here

<div ng-app>
  <div ng-controller="TeamListCtrl" class="checkboxList">
    <div id="teamCheckboxList">
      <li ng-repeat="result in results">
        <div class="col-sm-4" style="border:1px solid red;">
          <input type="checkbox" ng-click="vm.selectAll($event)" />
          <span class="lbl padding-8" style="color:#8b8b8b; font-size:12px !important">
            {{result.name}}
              <span style="color:#b0b0b0;">{{result.total}}</span>
          </span>

          <ul id="tp_{{result.subTipoPecaId}}">
            <li ng-repeat="peca in pecas" style="margin-left:25px;">

              <input type="checkbox" ng-click="vm.selectAll($event)" />
              <span class="lbl padding-8" style="color:rgba(139, 139, 139, 0.88); font-size:12px !important">
                {{peca.name}}
                  <span style="color:#b0b0b0;">{{peca.total}}</span>
              </span>

            </li>
          </ul>

        </div>

      </li>
    </div>
  </div>
</div>

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

`place the table inside a hidden div`

I am trying to create a non-editable table that can be overlayed with a div under specific conditions. However, it seems like my current implementation is not working as expected. What could be causing this issue? CSS <style type="text/css"> # ...

What is the best way to erase information displayed when hovering over an element using mouseout?

Whenever the user hovers over an image, an information box appears regarding that specific image. The information inside the box changes as I move over another image, but when not hovering over any images, the information box remains visible. Unfortunately ...

CSS :hover problem, text appearing unexpectedly

I'm currently working on designing a logo that displays hidden text when hovered over, providing instructions to users. However, I've encountered an issue where the hidden text reveals itself even before the logo is hovered over. This is frustrat ...

The $watch feature in AngularJS does not function properly within a directive when a controller is used to update data

I created a custom directive and also have a controller to bind data to the directive. The data is retrieved from the server and bound to the directive. However, I noticed that the data in the directive on the page does not update when I change the scope ...

I'm curious about how I can determine the reason why my badge is not accepting HTML tags in its tooltip

My goal is to integrate a bootstrap badge-alert with an HTML tooltip. I am following the example provided at https://getbootstrap.com/docs/4.3/components/tooltips/ Despite my efforts, when using the code snippet below, the tooltip appears but the HTML tag ...

Is it necessary to always include all styles for jQuery UI separately in my project?

While reading various articles, I have noticed a common suggestion to explicitly bundle each jQueryUI .css file, such as the answer provided on How to add jQueryUI library in MVC 5 project?. However, upon examining the .css files within the Content/themes/ ...

Encountered an error with the Angular fullstack generator while trying to run the '

Recently, I started developing a project using a yeoman angular-fullstack generator. Everything was working smoothly with the landing page loading correctly after running the grunt serve task. However, something has gone wrong, and now when I run grunt ser ...

Adjust the CSS styling to ensure that the div or iframe expands to fit the entire height of the

Having trouble making a map embedded via an iframe on a WordPress page display responsively at full height independent of the device? Check out: . To clarify, by full height, I mean that the bottom of the map should not extend beyond the screen, eliminati ...

Tips for transferring arguments to controller within the $mdToast.show method using Angular Material version 1.0.1

I'm working with angular-material and attempting to pass a parameter to $mdToast.show() within my controller. I can see there is a scope in the function, but I am struggling to implement it correctly. I have tried several expressions without success. ...

Tips for eliminating unwanted white space that appears before the "page-break-before: always" CSS code

For an example that can be replicated, check out this link - https://cbbanalytics.com/stats/27694/games/1864019/overview. We have applied a CSS style of page-break-before: always to the <h3> element containing the Stanford logo and text Stanford Team ...

`Trying to Implement jQuery Function with No Success`

My webpage includes the following HTML code: <div class="new-nav"> </div> Below is my jQuery script: var div1 = " <div class=\"metro-nav-block nav-block-orange\">\n <a data-original-t ...

Modify the c3 axis labels using CSS

I've been using the c3 package in R, which serves as a wrapper for the C3 javascript charting library created by Masayuki Tanaka. One issue I encountered is that my c3 chart was cutting off the last date on the x-axis. After inspecting it in Chrome I ...

Transfer information from a click event to a jQuery function

Having some trouble passing a C# list parameter to a jQuery method using onclick. It seems like the brackets [] and special characters in the string values are causing issues. For example, a string in the list might look like "*abc/def-". Any help would b ...

Using custom class instances or objects within Angular controllers is a simple process

Using three.js, I have created a class called threeDimView that houses my scene, camera, and other elements. In my JavaScript code, I instantiate a global object of this class named threeDimView_. threeDimView_ = new threeDimView(); Now, I wish to displa ...

The app.get method in Node.js and AngularJS has not been invoked before

I can't seem to figure out what's going wrong with my app.get function. When I look at the networking tab in Chrome, I see a HTTP status 302 Found error, but the function on the server side is not being accessed. I'm unsure of what the issue ...

Sending information to Bootstrap 4 modal

Can you help me insert the variable into this link? <a href="#edit_task" data-toggle="modal"><i class="fas fa-edit fa-lg fa-fw"></i></a> This is my modal: <div class="modal fade" id=" ...

The Glyphicon icon fails to appear on the initial page load and only shows up after refreshing the

I have been utilizing bootstrap.min.css from bootstrap v3.3.5 which I downloaded from http://getbootstrap.com and used it locally. However, I encountered an issue with glyphicons when running it on IE 9 and above. The glyphicon icon disappears on the first ...

Using CSS to align horizontally the legend of keys and values

I'm currently working on designing a horizontal legend using html/css. The design consists of colored boxes with text beside them, followed by some spacing, then another colored box with more text, and repeating in this pattern. [blue] - LabelA [g ...

Exploring the characteristics of images in Javascript

I've gone through my code multiple times but I just can't figure out why it's not functioning correctly... Could someone shed some light on this? What am I missing here? The purpose of the code is to allow users to input different values i ...

Why Jquery's nth-child selection and conditional formatting are failing to work

I am working with a table and need to format specific data fields based on their content. For instance, any field less than 95% should be highlighted in red. Below is the jQuery code I am using: $(function(){ $('#ConditionalTable td:nth-child(2n ...