使用angularjs显示/隐藏级联tr



我正在尝试在按钮单击时显示/隐藏。我试过了,

<tr>
<td colspan="2">
<button ng-click="visible = true">Calibration</button>
</td>
<td colspan="2"> Offsset                
</td>
<td colspan="3" > Multiplier
</td>
</tr>
<tr ng-if="visible" >  
<td colspan="5">
True value:
</td>                                                                                                     
<td colspan="2">         
<button ng-click="visible = false">Cancel</button>
<button ng-click="visible1 = true">OK</button>
</td>
</tr>
<tr  ng-if="visible1" >  
<td colspan="5" >
True value: <input type="text" name="val1" id="val1" style="width:50%"/>
</td>
<td colspan="2">   
<button ng-click="visible1 = false" >Cancel</button>
<button> OK </button>
</td>
</tr>

控制器就像

$scope.visible = false;
$scope.visible1 = false;

问题是校准按钮有效。但是另一个确定取消按钮不起作用。

如果,则使用ng show代替ng

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<table>
<tr>
<td colspan="2">
<button ng-click="visible = true">Calibration</button>
</td>
<td colspan="2"> Offsset                
</td>
<td colspan="3" > Multiplier
</td>
</tr>
<tr ng-show="visible" >  
<td colspan="5">
True value:
</td>                                                                                                     
<td colspan="2">   
<div>
<button ng-click="visible = false">Cancel</button>
<button ng-click="visible1 = true">OK</button>
</div>
</td>
</tr>
<tr  ng-show="visible1" >  
<td colspan="5" >
True value: <input type="text" name="val1" id="val1" style="width:50%"/>
</td>
<td colspan="2">   
<button ng-click="visible1 = false" >Cancel</button>
<button> OK </button>
</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.visible = false;
$scope.visible1 = false;   
});
</script>
<p>Use the ng-bind directive to bind the innerHTML of an element to a property in the data model.</p>
</body>
</html>

最新更新