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

asked Feb 6, 2013 at 12:19
1

1 Answer 1

4

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

request.parameter[parameter.key]
Jonatas Walker
14.3k6 gold badges57 silver badges82 bronze badges
answered May 19, 2014 at 14:26
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.