mardi 25 juillet 2017

AngularJS 1.5 need to have checkbox set to be checked with model of objects without ng-checked

Because of some other conflicts and dependencies , i'm not using angularjs 1.6.x , i'm using 1.5.x so i'm not sure if there is some bug - but I just know ng-checked is just awful

So I have ng-repeat

2 objects

  1. vm.stateList contains all 50 states
  2. vm.pager contains json like object in which if a state WAS selected it WILL be in the list

Thus I'm looping through displaying all the states as checkboxes, but I WANT to set them to be CHECKED - if they are found in my vm.pager object

 div ng-repeat="states in vm.statesList"

checkbox I want checked if in my object

 <input ng-model="vm.pager.location[$index].state" type="checkbox" id="state">

Example of data

Notice that the state is found in the location

{
  "Id": 105,
  "Name": "blah",
  "Description": "other data",
  "$$hashKey": "object:98",
  "location": [
    {
      "Id": 96,
      "state": "NY",
      "Order": 9,
    }
  ]
}




Aucun commentaire:

Enregistrer un commentaire