1

好的,所以我决定做一个预发布的 Angular,以利用 ngOptions 中新的“禁用时间”。我不确定我可以摆弄的范围。这是按预期工作的代码,删除了一个变量:

        <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>

所以我的问题是:我是否可以访问“何时禁用”的范围?如果我这样做,我做错了什么?

4

1 回答 1

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>

......它工作正常。这可能是一个错误,或者我的想法不好。然而,对于它的价值,有答案!

于 2015-05-22T17:55:32.913 回答