Html 了解Select选项的ng模型
我的控制器:Html 了解Select选项的ng模型,html,angularjs,angularjs-scope,ionic-framework,Html,Angularjs,Angularjs Scope,Ionic Framework,我的控制器: $scope.taglist = [{"name":"Fruit_Type","value":"0"}, {"name":"Leaves_Arrangment","value":"?"}, {"name":"Leaves_Margin","value":"?"}, {"name":"Leaves_Type","value":"?"}]; 这是我的表格 <form
$scope.taglist = [{"name":"Fruit_Type","value":"0"},
{"name":"Leaves_Arrangment","value":"?"},
{"name":"Leaves_Margin","value":"?"},
{"name":"Leaves_Type","value":"?"}];
这是我的表格
<form id="filter_form" onchange="angular.element(this).scope().fileNameChanged(this)" novalidate class="simple-form">
<div ng-repeat="(key, value) in tags.tags.objects | groupBy:'category.name'">
<div class="item item-divider">
{{ key }}
</div>
<label class="item item-input item-select" ng-repeat="(item_key, item) in value | groupBy:'subcategory.name'">
<div class="input-label">
{{ item_key }}
</div>
<select name="{{ key }}_{{ item_key }}" ng-model="taglist" ng-options="option.description for option in item">
<option ng-value="">------</option>
</select>
</label>
</div>
</form>
Currently selected: {{ taglist }}
为什么没有根据$scope.taglist设置选择选项?我的印象是这就是应该发生的事情。
因此,水果类型应选择选项0,其余选项无
我只是想让表单处于标记列表所处的状态对于要根据标记列表设置的选择选项,您应该在标记列表中使用ng options=value进行描述您说ng model=taglist,所以当前选择的是$scope.taglist-一个对象数组。看起来不错,但那不是你想要的。。。请参阅@CodingNinja的注释以了解ngOptions的内容,并为ngModel实际使用不同的变量,该变量应仅包含select对象,而不是整个数组。
Currently selected: [{"name":"Fruit_Type","value":"0"},
{"name":"Leaves_Arrangment","value":"?"},
{"name":"Leaves_Margin","value":"?"},
{"name":"Leaves_Type","value":"?"}]