ng-repeat: populate drop down options with array

29,369

why don't you use "ng-options" for select? take a lock at this AngularJs API: select

Share:
29,369
Josue Espinosa
Author by

Josue Espinosa

LinkedIn / GitHub / Portfolio

Updated on July 09, 2022

Comments

  • Josue Espinosa
    Josue Espinosa almost 2 years

    I have a simple JavaScript object that looks like this:

    $scope.obj = { "'Architect'": ["asdf","d","e","y"]};
    

    I'd like to show the values of 'Architect' in a select box. However, the single quotes are throwing me off when trying to do the ng-repeat.

    <select>
        <option ng-repeat="row in obj['Architect']" value="{{row}}">{{row}}</option>
    </select>
    

    That does not populate the select box, it just shows an empty select box. I assume it is interpreting the single quotes as a string literal, but even if I add single quotes and escape them, it still doesn't work as expected. Am I missing something?

    Here is a sample plunker: