2017-04-15 62 views
0

我試圖將值設置爲多個<select>標籤,如下圖所示。 <select>標籤沒有被選中,一切看起來都很好。在AngularJS中將值設置爲多個<select>標籤

什麼即時消息?

HTML:

<tr ng-repeat="t in tab track by $index"> 
<td>{{ $index+1 }}</td> 
<td>{{ t.name }}</td> 
<td>{{ t.phno }}</td> 
<td>{{ t.email }}</td> 
<td>{{ t.type }}</td> 
<td data-ng-show="user_type=='student' || user_type=='all'">{{ t.class_name }}</td> 
<td data-ng-show="user_type=='student' || user_type=='all'">{{ t.section_name }}</td> 
<td data-ng-show="user_type=='student' || user_type=='all'"> 
    <select data-ng-show="t.type=='Student'" ng-model="plan_id"> 
     <option value=''>--SELECT--</option> 
     <option ng-repeat="price in pricingList" data-ng-selected="{{t.plan_id == price.plan_id}}" value="{{price.plan_id}}">{{price.plan_name}}</option> 
    </select> 
</td> 
<td data-ng-show="msg=='s'"><input type="checkbox" data-ng-model="t.selected" value="{{t.id}}" data-ng-checked="Sall"></td> 
<td data-ng-show="msg=='r'">{{t.status}}</td> 
<td data-ng-show="user_type=='student' || user_type=='all'"> 
    <button type="button" data-ng-show="t.type=='Student'" ng-click="updatePlan(plan_id, t.id);">Update</button> 
</td> 

JS:

$scope.pricingList = [{"plan_id":1,"plan_name":"Free"},{"plan_id":2,"plan_name":"Basic"}]; 

    var URL=appURL+'/adm/loadSMSCollege.do'; 
    var json={"type":$scope.user_type, "class_id":$scope.class_id, "section_id":$scope.section_id, "created_by":$cookieStore.get("loginBean").created_by}; 
    $http.post(URL, JSON.stringify(json)).then(function(response){ 
     $scope.tab = response.data; 
     $scope.len = response.data.length; 
    }); 

樣品查看:

enter image description here

回答

2

試試這個。使用ng-options代替ng-repeat也改變模型t.plan_id

<td data-ng-show="user_type=='student' || user_type=='all'"> 
    <select data-ng-show="t.type=='Student'" ng-model="t.plan_id" ng-options="price.plan_id as price.plan_name for price in pricingList"> 
     <option value=''>--SELECT--</option> 

</select> 
</td> 
+0

作品完美地..我將外接U +1,當我得到一個資格..謝謝 –