AngularJS 1.4.0-rc.2 ngOptions禁用时

时间:2015-05-22 16:22:10

标签: angularjs angularjs-ng-options

好的,所以我决定我要做一个预发布的Angular来利用新的"禁用"在ngOptions中。我不确定我可以操纵的范围。这里的代码按预期工作,删除了一个varable:

        <select multiple ng-model="CoBorrowerIds" ng-options="person.Id as (person.LastName + ', ' + person.FirstName) disable when (person.Id==1) for person in Persons"></select>

禁用ID为1的数组。但是,我有这个代码不起作用:

        <select ng-model="BorrowerId" ng-options="person.Id as (person.LastName + ', ' + person.FirstName) for person in Persons"></select>

        <select multiple ng-model="CoBorrowerIds" ng-options="person.Id as (person.LastName + ', ' + person.FirstName) disable when (person.Id==BorrowerId) for person in Persons"></select>

所以我的问题是:我是否可以访问&#34;范围内&#34;?如果我这样做,我做错了什么?

1 个答案:

答案 0 :(得分:0)

我决定在父元素中添加ng-repeat语句,因此需要明确定义范围。它现在写着:

        <select ng-model="loan.BorrowerId" ng-options="person.Id as (person.LastName + ', ' + person.FirstName) for person in Persons" class="form-control"></select>{{BorrowerId}}

        <select multiple ng-model="loan.CoBorrowerIds" ng-options="person.Id as (person.LastName + ', ' + person.FirstName) disable when (person.Id==loan.BorrowerId) for person in Persons" class="form-control"></select>

......它运作正常。这可能是一个错误,或者我的思维差。然而,对于它的价值,有答案!