我有一个简单的 JavaScript 对象,如下所示:
$scope.obj = { "'Architect'": ["asdf","d","e","y"]};
我想在选择框中显示 'Architect'
的值。但是,在尝试执行 ng-repeat
时,单引号让我失望。
<select>
<option ng-repeat="row in obj['Architect']" value="{{row}}">{{row}}</option>
</select>
这不会填充选择框,它只是显示一个空的选择框。我假设它将单引号解释为字符串文字,但即使我添加单引号并转义它们,它仍然无法按预期工作。我错过了什么吗?
最佳答案
转义引号 How to properly escape quotes inside html attributes?
<option ng-repeat="row in obj["'Architect'"]" value="{{row}}">{{row}}</option>
关于javascript - ng-repeat:用数组填充下拉选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25654187/