data-binding not working on nested ng-repeat

When nesting ng-repeat it seems that clicking on the toggle button updates that addon in EVERY 'pair' (the first ng-repeat). Can anyone explain to me why this is the case and what I can do to fix it? Check the link above for the custom directive code...

<div ng-repeat="pair in pairs track by $index"> <h3>Pair {{ $index + 1}}</h3> <div class='fieldrow'> <button ng-repeat="addon in addons track by $index" toggle-button="addon.added">{{addon.name}} (£{{addon.price}})</button> </div> </div>

-------------Problems Reply------------

What is pair and what is addon, and how are they related. Right now, even though you have a nested ng-repeat, you have completely independent data structures, so addons array is same for each pair. Trott.

Based on this insight, I changed ng-repeat="addon in addons track by $index" to ng-repeat="addon in pair.addons track by $index"

Problem solved, thanks!

I think your code does not have any problem. see plunker here. this code is working well:

<div ng-repeat="pair in pairs track by $index">
<h3>Pair {{ $index + 1}}</h3>

<div class='fieldrow'>
<button ng-repeat="addon in addons track by $index" toggle-button="addon.added">{{addon.name}} (£{{addon.price}})</button>
</div>
</div>

Category:javascript Views:1 Time:2018-03-13

Related post

  • Flex - Data binding not working 2010-05-03

    I'm having some troubles with binding data. I have an application that contains a viewstack of components. Let's say I have comp1, comp2 and comp3 inside the viewstack. Each component, has its own data class --> comp1Data.as, comp2Data.as and comp

  • windows phone 7 silverlight user control: data binding not working on custom property 2011-07-24

    I have a rather simple user control (RatingControl) that has a dependency property defined as follows: public partial class RatingControl : UserControl { public RatingControl() { InitializeComponent(); } public static readonly DependencyProperty Rati

  • Simple-bound .NET data binding not working 2012-02-22

    Technology: .NET 4, C#, WinForms, Visual Studio 2010 I am in the processing of learning data binding and have been unable to get even a simple example to work as expected. I have a form with a label that I am binding to that shows the current mouse c

  • Custom UserControl "IsEnabled" data binding not working 2011-03-17

    I have a kinda awful problem with my WPF application right now... I have a custom UserControl used to edit details of a component. It should start by being not enabled, and become enabled as soon as the user chose a component to edit. The problem is:

  • Data binding not working, What is wrong? Silverlight WP7 2011-10-04

    I'm new to Silverlight and i'm trying to use Databinding. This looks simple but it's not working and I can't find why... In my MainPage.xaml <map:Map Name="bing_map" Height="578" Width="480" ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}" Center="{Bi

  • SAPUI5- Data binding not working 2014-09-01

    I am trying to bind data from controller to view but for some reason I am unable to display data in the view. I am setting the model using the following code: var oModel = new sap.ui.model.json.JSONModel(); oModel.setData(oObject); this.getView().set

  • How do I get 2-way data binding to work for nested asp.net Repeater controls 2010-03-12

    I have the following (trimmed) markup: <asp:Repeater ID="CostCategoryRepeater" runat="server"> <ItemTemplate> <div class="costCategory"> <asp:Repeater ID="CostRepeater" runat="server" DataSource='<%# Eval("Costs")%>'>

  • Data Binding not working for Datagird in wpf using Collectionview source 2014-08-05

    Here the code snippet for the data grid bind as static source of collection view source. But the datagrid not showing the required result. <Window.Resources> <local:EDiscoveryCoreDataList x:Key="CoreData"/> <CollectionViewSource x:Key=

  • Twoway Binding not working within DataGrid.Resources 2012-01-18

    I'm unable to get TwoWay Binding to work properly using DataGrid.Resources. The TextBox appears with the row on edit. When I exit off the row, the object that is bound to that row is not updated with the new value (tested with break points on the obj

  • ASP.NET MVC 2.0: Simple Model Binding not working/binding as it should 2010-03-01

    ASP.NET MVC 2.0: Simple Model Binding not working/binding as it should i have a simple custom object names Comment (linq to sql generated one), it has various values, but only two values are being sent from a HTML POST from to my action, and here is

  • Data connection not working- Lumia 720 2012-02-12

    Data connection not working for last few days, when switching the data connection on 3G, E, H logo does not appear next to network logo. Wifi working properly. --------------Solutions------------- Hello PrashantKumar21, Thanks for posting on the foru

  • Long date format not working from the Number format menue in excel 2010. 2014-02-21

    My long date format not working from the Number format menu in excel 2010. When I click on the long date in the number section on the home ribbon, it changes to the short date format. It appears that the formatting for this choose is missing. Can any

  • add date shortcut not working 2014-03-23

    I have Excel 2010 Slovak on Windows 7 Pro 64 bit Slovak. I cannot add date by shortcut Ctrl + ;. Ctrl + C, Ctrl + V are working. Thanks --------------Solutions------------- Hi, Thank you for asking. As I understand the shortcut to enter current date

  • mergefield for date format not working after a computer upgrade 2014-09-07

    I recently had a computer upgrade, Prior to the upgrade when I used the mergefield format for a date field I could use {MERGEFIELD REQUEST_DATE \ @ "MMMM d, yyyy" } and it would show properly as January 1, 2013, now it will only show 01/01/2013. Not

  • WPF DataTemplate Binding not working when used with an ItemsControl nested inside a ListBox 2011-06-21

    I have a UserControl that contains a ListBox that is bound to a CollectionViewSource called Data and each item in that collection is displayed in the ListBox using an ItemTemplate. That ItemTemplate is an ItemsControl that is bound to another Collect

  • AngularJs ng-if is not working for nested ng-if 2013-11-18

    In the code below the 2nd checkbox does not work when the 1st checkbox is clicked. http://plnkr.co/edit/JF0IftvWx7Ew3N43Csji?p=preview HTML: <html ng-app="App"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax

  • Data binding not updating 2009-08-07

    I created a simple example with data binding (unfortunately we have a similar case in our system). I created a funky combo box: public class FunkyComboBox : ComboBox { private object currentValue = null; public FunkyComboBox() { if (LicenseManager.Us

  • WPF - Why are changes to an object for a simple data-binding not reflected back to the target in the main window? 2010-02-03

    I am currently learning WPF (C#) and have taken the following simple data binding example from a text book which I am trying to get working. The example displays a simple window containing a name and age textbox and a Birthday button. The name and ag

  • flex data provider not working if XML has single node value or less 2010-05-20

    i get this error when i retrieve an XML that only has 1 node (no repeating nodes) and i try to store in an ArrayCollection. -When I have MORE than 1 "name" nodes...i do NOT get an error. My test show that XMLListCollection does NOT work either. TypeE

  • WPF MenuItem IsChecked Binding not working 2010-05-25

    Anyone know why the menu item binding does not work ? <ToggleButton Name="toggleButton" Checked="checkBoxPublish_Checked" > <ToggleButton.Resources> <converters:BooleanToHiddenVisibility x:Key="boolToVis"/> </ToggleButton.Resourc

  • Entity graphy binding not working in deep level 2010-11-08

    Suppose I have entity graph like People ->Student then in xaml, I have following kind of binding(People is property of VM): <TextBox Text="{Binding People.Name, Mode=TwoWay}" /> <TextBox Text="{Binding People.Student.StudentNo, Mode=TwoWa

  • MVC3 RC2 JSON Post Binding not working correctly 2011-01-07

    I've seen other posts on this subject and have fiddled with variations but still cannot not get the JSON model binding to work correctly. I have the following in my global.asax.cs Application_Start method: ValueProviderFactories.Factories.Add(new Jso

  • Windowbuilder Pro - selectedElement binding not working 2011-02-10

    Following a tutorial trying to learn Windowbuilder Pro and running into some problems. I have a list of an object, and want to create a binding function so that that when I've selected an object in the list, the corresponding objects name will appear

  • Binding not working Checked List BoX 2011-02-20

    Hi I have made checked List Box in WPF but the binding is not working correctly.I checked the List i created it contains the data in correct Format but when i bind it with the List box it does not work only Last entry appears in list box number of it

  • Jquery bind not working while within a javascript recursive loop 2011-05-03

    I am writing a piece of code that changes some lights on a screen from red to green randomly and waits for the user to hit the key that corresponds to the light lit. When I run this code you are able to hit the a,d,j or l key and an alert will pop up

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.117 (s). 11 q(s)