我在这里看到了Angular选择指令的文档:
http://docs.angularjs.org/api/ng.directive:select。
我不知道如何设置默认值。这是混乱:
我不知道如何设置默认值。这是混乱:
select as label for value in array
这里是对象:
{ "type": "select","name": "Service","value": "Service 3","values": [ "Service 1","Service 2","Service 3","Service 4"] }
html(工作):
<select><option ng-repeat="value in prop.values">{{value}}</option></select>
然后我试图在select元素中添加一个ng-option属性来将prop.value设置为默认选项(不工作)。
ng-options="(prop.value) for v in prop.values"
我究竟做错了什么?
所以假设对象在你的范围内:
原文链接:https://www.f2er.com/angularjs/147144.html<div ng-controller="MyCtrl"> <select ng-model="prop.value" ng-options="v for v in prop.values"> </select> </div>
function MyCtrl($scope) { $scope.prop = { "type": "select","Service 4"] }; }