sathish salvador
sathish salvador

Reputation: 320

How to use ngSelect for JSON

this is my json [["A","aaa"],["B","bbb"],["C","ccc"]] here the data 'aaa', 'bbb' and 'ccc' should be displayed in the dropdown when the data is selected their corresponding values ie 'A', 'B' or 'C' should be populated in the another variable

Upvotes: 0

Views: 45

Answers (2)

raulchopi
raulchopi

Reputation: 338

I have this selector:

%select{"ng-model" => "recipeDifficulty", "ng-options" => "d.description for d in difficulties"}

And when I select one and click in a button, in my controller I add it to a JSON:

recipe = { ... 'difficulty_id': $scope.recipeDifficulty.id, ... }

I get the values from a db table with two fields: 'id' and 'description'

Upvotes: 0

Josep
Josep

Reputation: 13071

Like this:

<select ng-model="yourModel" 
        ng-options="val[0] as val[1] for val in testData">
</select>

Example

Upvotes: 1

Related Questions