2017-07-04 61 views
0

我有兩列,我在其中動態生成選擇標籤。所以如果有四行,每列有四個選擇標籤。我希望第2列的第二個選擇標籤只能在第一個選擇標籤中的特定選項被選中時選擇。我使用angularjs在html中動態創建多個「單個」選擇標籤。兩列包含兩個不同的選擇標籤。我想要第二個

<tbody ng-init="count=0"> 

        <tr ng-repeat="a in CustomerCallDetails"> 
        <td colspan="1">{{a.first_name}} {{a.last_name}}</td> 
         <td colspan="1">{{a.date}}</td> 
         <td colspan="1">{{a.parent_classification_name}}({{a.parent_brand}})</td> 
         <td colspan="1">&#8377; {{a.customer_revenue | number}}</td> 
         <td colspan="1">{{a.phone}}</td> 
         <td> 
         <select><option ng-click="!disableSelect[count];count=count+1">Called</option><option selected="selected">Not Called</option></select> 
         </td> 
         <td colspan="1"> 
         <select ng-disabled="disableSelect[count]"><option>Called</option><option selected="selected">Not Called</option></select> 
         </td> 

        </tr> 

       </tbody> 

這是我至今嘗試過的代碼。但它似乎沒有工作。我的控制器中有一個for循環,它將disabledSelect定義爲true。我哪裏錯了?我對角度很陌生。也許這聽起來像是一個非常小的問題。

+0

後的代碼爲您的控制器或循環的NG-重複的數據。 –

+0

發佈JS。如果你可以發佈你想要的演示用戶界面將會更好 – himanshu

回答

0

你可以看看這個例子來推斷想法,並在你現有的代碼中進行調整。

HTML

<div ng-app="myapp"> 
    <fieldset ng-controller="FirstCtrl"> 
     <select 
      ng-options="p.id as p.first for p in people" 
      ng-model="selectedPerson"></select> 
     <select ng-disabled='selectedPerson === 2' 
      ng-options="p.id as p.actor for p in actor" 
      ng-model="selectedActor"></select> 
      selected person id: {{selectedPerson}} 
    </fieldset> 
</div> 

控制器

var myapp = angular.module('myapp', []); 
myapp.controller('FirstCtrl', function ($scope) { 
    $scope.people = [ 
     { id: 1, first: 'John', actor: 'Silvester' }, 
     { id: 2, first: 'Rocky',actor: 'Silvester' }, 
     { id: 3, first: 'John',actor: 'Arnold' }, 
     { id: 4, first: 'Ben',actor: 'Arnold' } 
    ]; 

     $scope.actor = [ 
     { id: 1, actor: 'Silvester' }, 
     { id: 2, actor: 'Silvester' }, 
     { id: 3, actor: 'Arnold' }, 
     { id: 4, actor: 'Arnold' } 
    ]; 
}); 

這裏的第一選擇下拉列表是爲人民,爲<option>值是人民的id。因此,每當選中id:2的人時,該演員的選擇下拉菜單被禁用。

爲您簡單做了進一步的實驗是鏈接到JSFIDDLE

+0

感謝這應該工作。 –

+0

我投了票,但當我剛加入社區時,它不會顯示我的投票。 –

+0

當然,我會投票 –

相關問題