Tuesday, 15 February 2011

AngularJS bind to dynamic model name -



AngularJS bind to dynamic model name -

i have generic json construction this

{ "parameters": [ { "key":"fieldname","posiblevalues":["val1,"val2"], "key":"anotherfield","posiblevalues":["vala,"valb"] } ] }

no want 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

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

so want setup model named "request.parameter.fieldname" (according "key" in json structure.

is possible? or have help myself ng-change?

thanks

if looking in way, can utilize next syntax:

request.parameter[parameter.key]

angularjs

No comments:

Post a Comment