Ng-repeat: populate dropdown options with array

I have a simple JavaScript object that looks like this:

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

I would like to show the values โ€‹โ€‹of 'Architect' in the selection box. However, single quotes throw me away when trying to do ng-repeat .

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

This does not fill the selection field, it just shows an empty selection field. I assume that it interprets single quotes as a string literal, but even if I add single quotes and avoid them, it still doesn't work properly. Am I missing something?

Here is a plunker example:

+5
source share
2 answers

avoid quotes How to avoid quotes inside html attributes?

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

http://plnkr.co/edit/6xUD3Zg0jxV05b41f2Gw?p=preview

+6
source

why don't you use "ng-options" to select? take castle AngularJs API: select

+1
source

Source: https://habr.com/ru/post/1201775/


All Articles