3

I have a generic JSON structure like this

{
 "parameters":
              [
                {
                  "key":"fieldName","posibleValues":["Val1,"Val2"],
                  "key":"anotherField","posibleValues":["ValA,"ValB"]
                }
              ]
 }

No I want to do something like this:

<div ng-repeat="parameter in parameters">
  <ng-form name="paramForm">
    {{parameter.key}}: <select ng-model="request.parameter.{parameter.key}" ng-option="..." />    
  </ng-form>


</div>

The problems comes with the

select ng-model="request.parameter.{parameter.key}"

So I want to setup a model that is named like "request.parameter.fieldName" (according to the "key" in the JSON structure.

Is this possible? Or do I have to help myself with a ng-change?

Thanks

Soccertrash
  • 1,830
  • 3
  • 28
  • 48
  • Ok, just found out myself: http://stackoverflow.com/questions/12553617/how-can-i-set-a-dynamic-model-name-in-angularjs?rq=1 – Soccertrash Feb 06 '13 at 12:22

1 Answers1

4

If someone is looking for anything in this way, you can use the following syntax:

request.parameter[parameter.key]
Jonatas Walker
  • 13,583
  • 5
  • 53
  • 82
Nico
  • 255
  • 2
  • 12