【问题标题】:Binding ng-model to ng-options selection将 ng-model 绑定到 ng-options 选择
【发布时间】:2016-08-25 20:22:06
【问题描述】:

我很难从使用 ng-options 构建的选择框中将选择绑定到 ng-model。最终,我想包含一些选择框,它们充当级联过滤器,从数组动态构建

这就是我所得到的 - 问题是“loc”没有从选择框中获取选定的选项。

            <th class="col-sm-1">Location
                    <select class="form-control input-sm" name="aws_child_loc_stat" ng-model="loc" ng-options="loc as aws.child_loc_stat for aws in aws | unique: 'child_loc_stat'">
                    </select></th>

请戳这里:http://plnkr.co/edit/lhRl1GMxnNeD8qUO0HNm

【问题讨论】:

    标签: angularjs html-select angular-ngmodel ng-options


    【解决方案1】:

    您的ngModelvaluengOptions 中定义的属性相同 - 这很糟糕。让您的 ngModel 与众不同:

    <select class="form-control input-sm" name="aws_child_loc_stat" ng-model="selectedLoc" ng-options="loc as aws.child_loc_stat for aws in aws | unique: 'child_loc_stat'">
    

    【讨论】:

    • 那行不通。 Plunk 已更新。我错过了什么吗?