Skip to content Skip to sidebar Skip to footer

Angularjs Doesn't Bind Ng-checked With Ng-model

I have googled this and found out that people had this issue, but I haven't found any solution. So this is my code %section(ng-controller='UserCtrl' ng-init='user_genres=#{prefe

Solution 1:

I'm not certain I understand what the real problem is, but see if this fiddle is what you want. (I obtained a list of preferred_genres from your other post.)

The controller scope property preferred_genres is being updated based on the checkbox state:

<li ng-repeat="(genre, checked) in preferred_genres">
  <input type="checkbox" ng-model="preferred_genres[genre]"id="genre-{{$index + 1}}">

As @dnc253 mentioned in your other post, you probably don't need ng-checked since each item has its own ng-model.

Post a Comment for "Angularjs Doesn't Bind Ng-checked With Ng-model"