javascript - Can not remove the expected row from table using Angular.js -


i have issue.i need remove 1 particular row table structure of app using angular.js.my code present inside below plunkr link.

code present here

in above code create 3 row monday , fill required data should different each row.delete middle row using - button,you can check there last row subcategory showing wrong.this problem.i need if deleting particular row row data should remove array , other row remain constant selected data was.please me.

i edited plunker : https://plnkr.co/edit/4okacc?p=preview

your problem in use of $index in ng-repaet. when delete middle row $index of third row change , reference wrong catgeory. change plunker use function return subcategories depends on selected category :

$scope.getsubcategoryfor = function(answer) { if(!answer.category) {   return []; }    console.log(answer);   var result = $filter('filter')(subcategories, {id:answer.category.id});   console.log('result', result);   return result; } 

and use in html :

<table>         <tbody>           <tr ng-repeat="answer in d.answers">             <td>               <select class="form-control" id="answer_{{$index}}_subcategory" name="answer_{{$index}}_subcategory" ng-model="answer.subcategory" ng-options="sub.name sub in getsubcategoryfor(answer)">                 <option value="">select subcategory</option>               </select>             </td>           </tr>         </tbody>       </table> 

i hope you


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -