Angularjs 数据绑定与ng选项下拉列表(角度)

Angularjs 数据绑定与ng选项下拉列表(角度),angularjs,data-binding,drop-down-menu,ng-options,Angularjs,Data Binding,Drop Down Menu,Ng Options,我有一个下拉列表,我想显示一个基于角度下拉选择的值。我正在使用ng选项,并且认为一个简单的数据绑定应该可以工作,但是数据绑定没有显示出来。这里有一个小插曲: 在这方面: {{cust_info.Name} 您试图错误地引用名称,您有一个对象数组,每个对象都有名称,因此无法正常工作 将其更改为: {{cust_info[defcust-1].Name} -1,因为“客户”从1开始,而不是0 您将在cust\u info中获得第n个索引,其中第n个索引由用户选择并存储在defcust中 {{cust

我有一个下拉列表,我想显示一个基于角度下拉选择的值。我正在使用ng选项,并且认为一个简单的数据绑定应该可以工作,但是数据绑定没有显示出来。这里有一个小插曲:

在这方面:

{{cust_info.Name}

您试图错误地引用
名称
,您有一个对象数组,每个对象都有
名称
,因此无法正常工作

将其更改为:

{{cust_info[defcust-1].Name}

-1,因为“客户”从1开始,而不是0

您将在
cust\u info
中获得第n个索引,其中第n个索引由用户选择并存储在
defcust


{{cust_info[defcust-1].Name}}应该可以按预期工作

不使用索引来实现这一点,我想需要更多的javascript。。我加了一些。希望这有帮助。。看到这个演示了吗

<select ng-model="defcom" ng-change="change_acc(defcom)"
    ng-options="opt.DefCom as opt.DefCom for opt in acct_info | filter:{Req:'MUST'}:true" >
  </select>
  <select ng-model="defcust" ng-change="change_cust(defcust)"
    ng-options="opt.Customer as opt.Customer for opt in cust_info | filter: {Com: defcom}: true">
  </select>

http://plnkr.co/edit/pf6PtOWANfLxulQupqZq?p=preview

http://plnkr.co/edit/pf6PtOWANfLxulQupqZq?p=preview

另一个用户是对的,如果按索引,则需要-1。如果我不想按索引选择,而是按所选选项选择,该怎么办?例如:我在不使用索引的情况下成功地做到了这一点,但随后我丢失了默认值:
$scope.cust_info = [
      {
        "Customer": "1",
        "Com": "1",
        "Name": "First Name"
      },
      {
        "Customer": "2",
        "Com": "1",
        "Name": "Second Name"
      },
      {
        "Customer": "3",
        "Com": "4",
        "Name": "Third Name"
      }];
<select ng-model="defcom" ng-change="change_acc(defcom)"
    ng-options="opt.DefCom as opt.DefCom for opt in acct_info | filter:{Req:'MUST'}:true" >
  </select>
  <select ng-model="defcust" ng-change="change_cust(defcust)"
    ng-options="opt.Customer as opt.Customer for opt in cust_info | filter: {Com: defcom}: true">
  </select>

http://plnkr.co/edit/pf6PtOWANfLxulQupqZq?p=preview