2015-05-22 43 views
1

禁用時,AngularJS 1.4.0-rc.2禁用,所以我決定我要做一個預發佈的Angular來利用ngOptions中新的「disable when」。我不確定我被允許擺弄的範圍。下面是代碼按預期一個varable取出時運作:AngularJS 1.4.0-rc.2當

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

所以我的問題是:我有權訪問「禁用時」內的範圍?如果我這樣做,我做錯了什麼?

回答

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> 

...它工作正常。這可能是一個錯誤,或者我的糟糕的想法。但是,它的價值是什麼,答案就是這樣!