angularjs - ng-switch for a particular row in a ng-repeat table -


i need implement switching of buttons. here getting data json file populate table using ng-repeat. when click 'edit' button, edit buttons in table getting switched 'save' buttons. want particular button switched. please in issue.

<tr data-ng-repeat="host in hosts|filter:search:strict" ng-switch on="editsave">     <td>{{host.hostcd}}</td>     <td>{{host.hostname}}</td>     <td>       <span ng-switch-when="false"><button style="width:50px;" class="btn btn-mini btn-warning" data-ng-click="edit()"><b>edit</b></button></span>       <span ng-switch-when="true"><button style="width:50px;" class="btn btn-mini btn-success" data-ng-click="save()"><b>save</b></button></span>        <button class="btn btn-mini btn-danger deleterow"><b>delete</b></button>     </td> </tr> 

script

$scope.editsave = false; $scope.edit = function() {     $scope.editsave = true; }; $scope.save = function() {     $scope.editsave = false; }; 

another alternative:

<tr data-ng-repeat="host in hosts|filter:search:strict" ng-init="host.editsave = false">     <td>{{host.hostcd}}</td>     <td>{{host.hostname}}</td>     <td>       <span ng-hide="host.editsave"><button style="width:50px;" class="btn btn-mini btn-warning" data-ng-click="edit(host)"><b>edit</b></button></span>       <span ng-show="host.editsave"><button style="width:50px;" class="btn btn-mini btn-success" data-ng-click="save(host)"><b>save</b></button></span>        <button class="btn btn-mini btn-danger deleterow"><b>delete</b></button>     </td> </tr> 

script

$scope.edit = function(host) {    host.editsave = true; }; $scope.save = function(host) {    host.editsave = false; }; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -