-1

I have a multi dimensional array I want to print all data with check box. there is dietry_reqs array below in the code I want to create check box with these value which value is true that will selected. How to put dietry_reqs in ng-repeat

{  
   "attendance":[  
        {  
         "id":"13",
         "event_booking_id":"19",
         "seat_type":"",
         "fname":"",
         "lname":"",
         "email":"",
         "company":"",
         "dietry_reqs":[  
            {  
               "id":1,
               "name":"delhi",
               "value":false
            },
            {  
               "id":2,
               "name":"mumbai",
               "value":false
            },
            {  
               "id":3,
               "name":"ahmedabad",
               "value":false
            }
         ],
         "attend_status":"0",
         "created":"2016-05-04 11:41:28"
      }
   ]
}

This is my code I have not written all fields code. I called check box like that but i am getting response as below image

<div class="row" ng-repeat="itemse in items track by $index">
            <div class="col-md-1">
                <div class="form-group" mod="itemse">
                    <select class="form-control" name="seat_type" ng-model="itemse.seat_type">
                        <option ng-selected="selected" value="Table">Table</option>
                        <option value="Individual">Individual</option>
                   </select>
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group" mod="itemse">
                     <input type="text" class="form-control" name="fname" placeholder="First Name" ng-model="itemse.fname" focus/>
                </div>
            </div>
         <div class="col-md-2">
                <label ng-repeat="itemcheck in itemse.dietry_reqs track by $index">
                 <input type="checkbox" value="{{itemcheck.value}}">{{itemcheck.name}}
                </label>
            </div>
        </div>

enter image description here

0

1 Answer 1

0

you did not provided enough code but as far as i understand, you can do something like that:

   <div ng-repeat="level1 in attendance">
      <div ng-repeat="level2 in level1.dietry_reqs">
         <input type="checkbox" value="{{level2.value}}">{{level2.name}}
      </div>
   </div>
Sign up to request clarification or add additional context in comments.

3 Comments

I did like that but I am getting repeated check box
then please give more detail about your question because you mentioned to display all data with checkbox?
<label ng-repeat="itemcheck in items.dietry_reqs"> <div ng-repeat="(key, value) in itemcheck"> {{key}} : {{value}} </div> When I am printing this array in side the loop I am getting "every character" is like key and value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.