Angularjs - Populate select box using ng-options -


i have json object below

keyword = {     application: ["athena","ewindow","ews","fact","ftp","hardware","pen","hermes","infrastructure","lng tracker","m2m","maintenance","microsite","oracle","platts.com","pmc","pto task","sametime","third party data","user error","vendor","web channels","xml-dd","customer request","mark logic","sbb","market engagement form","lotus notes database","oracle11i","external news","stringers","prp","kingsman","hermes-1"],     incidenttype: ["publishing failure","brand damage","security failure","content creation failure","internal failure","external failure","system failure","operational failure","editorial failure","content inaccuracy","process failure","application issue","infrastructure issue","user issue","other","resend","data send validation","customer issue"],     incidentenvironment: ["production","non-production","others"],     incidentpriority: ["low","medium","high","critical"],     incidentlocation: ["asia pacific","europe","new york","new jersey","houston","washington dc","others"],     incidentstatus: ["initiation","work in progress","completed","on hold","closed","cancelled"],     incidentcategory: ["activex","checkin","checkout","ckeditor","corrupt story","delete story","delivering content","download-upload","filter","graph-rich media","ie cache","ie setting","indicia","indesign","infrastructure","ingest(table)","other","pdf","publish","search","table","user issue"],     incidenttickettools: ["bmc remedy"], } 
<div class="col-lg-3">     <select name="txt_inc_status" class="form-control input-sm" required>         <option selected disabled>             -- select status --         </option>         <option ng-repeat="incidentstatus in keywords.incidentstatus" value="{{incidentstatus}}">             {{incidentstatus}}         </option>     </select> </div> 

i need populate these values in select boxes. ex: keywords.application in application select box , on.

earlier used ng-repeat construct options. came know not advised so.

so trying use ng-option facing difficulties in populating this. can me on this?

also need select default value (random) these selectbox. how can achieved. didn't work when used ng-repeat

you can use

<div ng-repeat="(key, value) in keywords">     <select ng-options="item item in value" ng-init="index = getrandomindex(value)" ng-model="value[index]">{{item}}</select> </div> 

together function random index current array

$scope.getrandomindex = function(item){     var index = math.floor((item.length * math.random()));     return index; } 

demo


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -