user311121
user311121

Reputation: 319

How do I use ng-select inside an ng-repeat?

I'm writing an angular app to manage a REST service that manages configuration information (think: application.properties, in the cloud).

One type of response I get from my REST service is a collection of observed dimensions that I'd like to iterate over and create drop down menus for.

Here's a JSFiddle showing what I'm trying to do: http://jsfiddle.net/tvaughan/3Lp9c/17/

     <div ng-repeat="(dim, values) in observedDimensions">
        <select ng-options="val for val in values" name="dim-{{dim}}">
            <option value="">-- select a {{dim}} --</option>
        </select>
        {{dim}} : {{values}}
        <br/>
    </div>  

Note that the observed dimensions are properly spitting out as plain text to the right of the select boxes, but that the select boxes themselves seem to be out of scope of the "dim" and "values" elements. I think I understand that the ng-repeat creates a new scope, but using "parent.values" or $parent.values" doesn't work either...

What am I doing wrong here?

Thanks in advance!

Upvotes: 1

Views: 6356

Answers (1)

dnc253
dnc253

Reputation: 40327

The problem is that you don't have an ng-model on your select. See http://jsfiddle.net/3Lp9c/19/

Upvotes: 4

Related Questions