Using ng-repeat within an <input> element does not function as expected when nested

Upon examination of my $scope parameter, I have come across the following structure:

$scope.filters = [{name: "Brands", brands: ['Brand1', 'Brand2', 'Brand3']}, 
                 {name: "Catalogs", brands: ['Cat1', 'Cat2', 'Cat3']}];

When attempting to display this data as a list in the HTML file, I utilized the following code snippet:

<div ng-repeat="filter in filters"><h3>{{filter.name}}</h3>
            <input type="checkbox" ng-repeat="brand in filter.brands"> {{brand}}<br>
        </div>

The filter.name displays correctly with values like "Brands" and "Catalogs", yet the checkboxes remain empty below them. The only workaround that works is removing the ng-repeat from the input tag and placing it outside using a label or similar element.
Is there something crucial that I am overlooking here?

Answer №1

just like that

var application = angular.module("application",[]);
application.controller("controller" , function($scope){
  $scope.filters = [{name: "Categories", categories: ['Category1', 'Category2', 'Category3']}, 
                 {name: "Items", categories: ['Item1', 'Item2', 'Item3']}];
  
  })
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="application" ng-controller="controller">
<div ng-repeat="filter in filters"><h3>{{filter.name}}</h3>
     <div  ng-repeat="category in filter.categories">
        <input type="checkbox" ng-model="categories"> {{category}}<br>
     </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

Error: Improper hook call detected with no hooks being used (material-ui v5)

I've created the following basic application: import Grid from '@material-ui/core/Grid'; function App() { return ( <div className="App"> <Grid container spacing={2}> <Grid item xs={8}> ...

What are the implications of incorporating listeners in redux action creators?

While developing my app, I have a feature that involves constantly monitoring location changes and updating the store accordingly. One question that has arisen is whether it would be beneficial to keep the listeners inside the action creator rather than th ...

Simple way to automatically update Ionic List

I'm attempting to automatically refresh a list displayed using Ionic 1. I came across this codepen, but I'm having trouble grasping how it functions. https://codepen.io/calendee/pen/GkgsD?editors=1111 Below is the code for the list that I am ...

Employing a script that is generated from the jQuery AJAX response

How does using script as the response for a jQuery/AJAX request benefit us? Is it possible to directly run a function from that response script after sending the AJAX request? Any simple examples would be much appreciated. ...

This article will discuss how to send back an HTML response and include a cookie using Cloud

I'm trying to achieve the dual task of setting a 'Set-Cookie' response header and modifying an HTML response by adjusting CSS. Essentially, I want to combine these two actions into one (or consolidate my two IF statements): const country = ...

conceal the mustard-colored dots within the overlay

Whenever I trigger the link, a modal window pops up, but it comes with an unwanted black background color and yellow dots. How can I prevent the yellow dots from showing up on the overlay? http://jsfiddle.net/y88WX/18/embedded/result/ <nav class="da-d ...

Is there a formatting error when pulling data from an API using Angular?

The data retrieved from the API follows this format: { “array1”:[ {"id”:1, ”someProperty”:”A"}, {"id":2, "someProperty”:”B”} ], “array2”:[ {"id”:1, ”anotherProperty”:”foo”, ”lastProperty”:”foo2”}, ...

Accessing files outside of the root directory in a Meteor application

I am looking to access a library of images located outside the meteor application directory. I plan to have multiple components using this library, so it will not be solely dedicated to the application. All of the components - including the meteor app, ima ...

What is the method for expanding this schema array using mongoose?

In the user schema below, I'm focusing on updating the ToDo section under User.js. My goal is to include new data to an array within the database. data.js app.post("/data", loggedIn, async (req, res) => { console.log(req.body.content); ...

Error: JQuery Ajax Success Handler cannot locate class method

There is a javascript Class in my code that successfully posts data, but encounters an issue when trying to access a specific function within a success handler. Although the function is found during the construction of the class and can be called from othe ...

Associate text with a color from a predetermined list (JavaScript)

As I work on adding tags to my website for blog posts, I have a specific vision in mind. Each tag should be assigned a unique background color selected from a predefined array of theme colors. My goal is to assign the same background color to tags with id ...

Sort through a collection of objects using various criteria

The information is structured as follows: export const data = [ { id: 1, company: "Photosnap", logo: "./images/photosnap.svg", new: true, featured: true, position: "Senior Frontend Developer", ...

Fuzziness occurrence in distinct vue element

My Situation I have a custom DropDown with a filter text input above. The DropDown can be opened independently from the filter text input. My Goal I want the DropDown to close when the filter input loses focus and also when I click outside of the Drop ...

Associating models using a many-to-many relationship in Sequelize unexpectedly restricts the ability to modify attributes in the join table

I am in the process of incorporating a voting feature into my app, allowing users to vote on responses from other users. The backend of my Node app is built using Express and Sequelize. Currently, I am utilizing a SQLite database for testing convenience. ...

Tips for adding HTML table information to a database

I have a table in HTML where one column can be edited, and I need to save that data into my database. Firstly, here is the code snippet: var tableData = [{ "Item Code": "C001", "Item Name": "Beverages", "Quantity": "0" }, { ...

Not successfully integrating an angular component

In my Angular application, I am working on creating a new component and injecting it into the app. Below is the code for the angular component: (function(angular) { 'use strict'; angular.module('some.someModule', ['bm.component.t ...

Storing data values from a specific object key into an array in Vue: Step-by-step guide

Just dipping my toes into the world of Vue framework here. I managed to create a selectable table that stores data in an object. I want this function to run in the background, so I figured it should be in the computed section. The object structure is as fo ...

Tips for typing the following object/type in TypeScript

I need help with typing a user state in my application. I have the following: a user type which includes id, email, firstName, lastName, and verified fields. export type User = { id: string | null; email: string | null; firstName: string | null; l ...

Obtaining the class names, dividing them, and then inserting the resulting array into a

In my bar, users are able to toggle "buyers". Once a user selects one of the buyers, jQuery adds the class "selectBuyerOn." Upon submitting, a new div will appear and I want the list of buyer names to be displayed there. <div class="buyerNam ...

Mastering the art of looping and implementing logic in JavaScript using Regular

Unsure if it is possible to achieve this using regex under JavaScript, but I found the concept interesting and decided to give it a try. I wanted to clean up some HTML code by removing most tags completely, simply dropping them like <H1><img>& ...