我有一个指令用于展开和折叠表格中的数据行:
angular.module('rokoApp')
.directive('dir', function() {
return {
link: function(scope, elem) {
$(elem).on('click', function() {
$(this)
.parent('tr')
.next('tr')
.toggle();
});
}
};
});
这是ng-repeat代码:
<tr ng-repeat-start="data in totalsum" ng-click="isRowCollapsed=!isRowCollapsed">
<td>
<input class="form-control" placeholder="{{data.total | number:2}}">
</td>
</tr>
<tr ng-repeat-end ng-show="data.breakdown.length>0" ng-hide="isRowCollapsed">
<td ng-show="data.breakdown.length>0">
<div class="subvalues" ng-repeat="subvalues in data.breakdown">
<input class="form-control" placeholder="{{subvalues.subtotal | number:2}}">
</div>
</td>
</tr>
<tr>
<td>
<input class="form-control" placeholder="{{getTotal('total') | number:2}}">
</td>
</tr>
我希望在点击一行时展开所有隐藏数据行。