2017-04-15 7 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

これを試してください。私は資格を得るとき..私はUに+1を追加するも完全に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

作品にモデルを変更ng-options代わりng-repeatの使用..あなたに感謝 –

関連する問題