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.
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
Post a Comment