title: AngularJS using ngModel to get complex object from Checkbox set
body: <p>Good Morning!</p>
  
  <p>I've found several posts on stack that touch on this, but I haven't found any that accomplish what I'm trying to do exactly.</p>
  
  <p>(JS Fiddle for Reference: <a href="http://jsfiddle.net/gsLXf/1/" rel="nofollow">http://jsfiddle.net/gsLXf/1/</a>)</p>
  
  <p>I have a dynamic set of questions that I am asking as part of a survey.  I have figured out how to bind the responses in text and radio responses to a 'response' object that I can post back to my server.  The problem I am having is with Checkboxes.  As you can see in the fiddle, when I try to do </p>
  
  <pre><code>ng-model="response[question.id]"
  </code></pre>
  
  <p>all of my checkboxes respond as one item (which makes sense since they are all bound to the same value.  However, when I use </p>
  
  <p><code>ng-model="response[question.id][option.id]"</code></p>
  
  <p>I pop an error because question.id hasn't been instantiated yet so option.id can't be pushed onto the object.</p>
  
  <p>Ideally my response object for the referenced fiddle would look like this:</p>
  
  <pre><code>{
     "123456": "2", //radio question
     "789012": //checkbox question 
         ["5", "6"] //list of checkbox options ids selected
  }
  </code></pre>
  
  <p>My users will be creating forms dynamically, so I have to be able to handle this very gracefully in all situations.  I can't hard-code ANY object related data into a controller and I can't hand-create model objects to handle this situation.</p>
  
  <p>I have considered looping through the known ID set to scaffold a response object to be filled during initialization, but it seems like overkill when Angular has such a nice way of just creating a response object on the fly (except for this situation).</p>
  
  <p>What is the best way to go about doing this?</p>