1
現在,下面的代碼顯示了一個包含點擊時展開/收縮的行的表格。我希望每行都能在點擊時將內容向下滑動。我該怎麼做呢?動畫擴展/縮小表
function MyCtrl($scope) {
$scope.environment_service_packages =
[
{name: 'Click to expand', info: {text: 'some extra info', show: false}},
{name: 'obj2', info: {text: 'some extra info for obj2', show: false}},
];
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
<table ng-controller="MyCtrl" class="table table-hover table-striped">
<tr class="info">
<td>...</td>
</tr>
<tbody ng-repeat="x in environment_service_packages">
<tr ng-click="x.info.show = !x.info.show">
<td> {{ x.name }}
</tr>
<tr ng-show="x.info.show">
<td>
{{ x.info.text }}
</td>
</tr>
</tbody>
</table>
</body>
有關使文本和表格滑下的其餘部分是什麼? – Jez
爲此,您可以使用ng-class並根據條件爲其添加特定的動畫樣式。就像我想你在展開/摺疊時想要上移或下滑一樣 – Srijith