How to deal with nested data in Angular.js select in a form?


I have a node.js app where the form has a selector. The app loads the data from mongodb via mongoose and populates a nested referenced object. So my data looks like:

{ "__v" : 0,
  "_id" : ObjectId( "51199c96c13e06ae33000001" ),
  "consortium" : 
     { _id: '510f234198e6c75a3a1b43eb',
       imageURLsm: '/asdf.jpg',
       name: 'COOLNAME' },
  "description" : "My Description",
  "gdp" : 1234,
  "imageURL" : "",
  "location" : "",
  "name" : "My Cool Name",
  "ownerKey" : "d15e6de2-66c0-4e0c-a0bc-2023b65e87d0",
  "ownerName" : "Asdf Jkls",
  "parcelId" : "eb7fxbc4-581f-83c7-6abe-6e1e0474520f",
  "people" : 1 }

Then in my jade template I have:
    label(for='name') Name:
    input(ng-model='', name='name')
    label(for='description') Description:
    textarea(ng-model='form.description', name='description', cols='50', rows='15')
    label(for='') Consortium:
    select(ng-model='', name='', ng-options=" for consortium in consortia")
    label(for='gdp') GDP:
    input(ng-model='form.gdp', name='gdp')
        button(ng-click='savePlanet()') Save

When I click the save button, it saves everything except the consortium. The list of various consortiums properly populates because elsewhere, I have set $scope.consortia to equal all the various ones. And whenever I visit this form, the existing saved consortium does not show up as selected. What do I need to change about my select expression in order that it properly saves the consortium?

I am properly populating consortium when supplying the data from the planet model, so in the browser, you do in fact get all the above data. It's there. But I just don't know what I'm supposed to do with this select expression. Any help would be most appreciated!!

Problem courtesy of: CommaToast


select(ng-model='form.consortium._id', name='consortium._id', ng-options="consortium._id as for consortium in consortia")

Worked perfectly.

Solution courtesy of: CommaToast


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.