Skip to main content
spelling
Source Link
Jason Aller
  • 3.7k
  • 28
  • 42
  • 40

I have a list of checkboxes as following  :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whithwith values from the database and then I can see the ones wichwhich was selected.

The problem I have is the checkboxscheckboxes are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemntselements, they are not selected.

this is a plunker for the working case  :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case  :

http://plnkr.co/edit/82FDQlhTtd09scs9cCDz?p=preview

Why I'mam I getting this behavior, and how can I solve it  ?

I have a list of checkboxes as following  :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whith values from the database and then I can see the ones wich was selected.

The problem I have is the checkboxs are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemnts, they are not selected.

this is a plunker for the working case  :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case  :

http://plnkr.co/edit/82FDQlhTtd09scs9cCDz?p=preview

Why I'm getting this behavior, and how can I solve it  ?

I have a list of checkboxes as following:

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array with values from the database and then I can see the ones which was selected.

The problem I have is the checkboxes are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elements, they are not selected.

this is a plunker for the working case:

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case:

http://plnkr.co/edit/82FDQlhTtd09scs9cCDz?p=preview

Why am I getting this behavior, and how can I solve it?

edited body
Source Link

I have a list of checkboxes as following :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whith values from the database and then I can see the ones wich was selected.

The problem I have is the checkboxs are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemnts, they are not selected.

this is a plunker for the working case :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case :

http://plnkr.co/edit/JSibuMKNEEBckJDxgpiI?p=previewhttp://plnkr.co/edit/82FDQlhTtd09scs9cCDz?p=preview

Why I'm getting this behavior, and how can I solve it ?

I have a list of checkboxes as following :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whith values from the database and then I can see the ones wich was selected.

The problem I have is the checkboxs are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemnts, they are not selected.

this is a plunker for the working case :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case :

http://plnkr.co/edit/JSibuMKNEEBckJDxgpiI?p=preview

Why I'm getting this behavior, and how can I solve it ?

I have a list of checkboxes as following :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whith values from the database and then I can see the ones wich was selected.

The problem I have is the checkboxs are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemnts, they are not selected.

this is a plunker for the working case :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case :

http://plnkr.co/edit/82FDQlhTtd09scs9cCDz?p=preview

Why I'm getting this behavior, and how can I solve it ?

Source Link

Bind a list of checkboxes in AngularJS

I have a list of checkboxes as following :

<div ng-repeat="formationType in formationTypeList">
  <label>
  <input type="checkbox" class="md-warn md-align-top-left"
    ng-model="formationSelection[$index]" 
    ng-true-value="{{formationType}}" 
    name="formationSelection[]">
    {{ formationType.nom }}
  </label>
</div>

As you can see this checkboxes are initialized with values in formationSelection[] array.

And when I check some checkbox the value of this checkbox is added to that array.

The formationTypeList contains a list of objects, each object is attached to a checkbox.

In my scenario the first time I have the formationSelection[] empty so when I check some checkboxes and I send my form the values in that array will be stored in a database, and when I back o my application I want to see the checkboxes I've selected so I populate that array whith values from the database and then I can see the ones wich was selected.

The problem I have is the checkboxs are only selected in one case if I have in formationSelection[] the first element or the first, second elements or the first, second and third elements, but when I have for example the second and the fourth elemnts, they are not selected.

this is a plunker for the working case :

http://plnkr.co/edit/I7NK8Tkw3Rzwh1Zj2X78?p=preview

and this is a plunker for the non working case :

http://plnkr.co/edit/JSibuMKNEEBckJDxgpiI?p=preview

Why I'm getting this behavior, and how can I solve it ?