arrays - JSON to angular select with ng-options -


i attempting json encoded response ajax request select statement using angular ng-options. not have control of php source of json response comes from.

the response in form:

{"a":"col1","b":"col2","c":"col3","d":"col4"} 

i using simple select dropdown , need populate above json utilizing index set value , value set dropdown text. example below.

<select ng-model="selecteditem" ng-options="item item in items"> 

options should result in this:

<option value="a">col1</option>   <option value="b">col2</option> <option value="c">col3</option> ... 

i unsure missing format of json response it'll used in ng-options. i've tried forms of ng-options no avail. i've tried format response json.parse, json.stringify, .eval(), etc.

considering json_encoded array correct object when hit angular function, able working keeping object , manipulating ng-options key, value configuration. code below.

<select ng-options="k v (k, v) in cols"></select>

jsfiddle

i referenced post here: ng-options object data source

this worked out because don't have control on json encoded array coming controller needed reference key value options of select instead of letting angular let own thing it.


Popular posts from this blog

html/hta mutiple file in audio player -

debugging - Reference - What does this error mean in PHP? -