我有这个填充程序http://jsfiddle.net/LgrNF/245/ 我试图做的是当用户点击数字1打开下面的行号1并显示消息:“一些消息”,如果他点击数字2打开行号2,依此类推。但我有一点点问题。有什么建议吗?
app = angular.module("App", []);
app.controller("AppCtrl", function($scope) {
$scope.message = "Some message";
$scope.items = [1,2,3,4,5,6,7];
$scope.toggleDetail = function($index) {
//$scope.isVisible = $scope.isVisible == 0 ? true : false;
$scope.activePosition = $scope.activePosition == $index ? -1 : $index;
};
});
编辑:我上传了新的小提琴手,我在页面底部收到消息
答案 0 :(得分:1)
通过在tbody
而不是tr
添加重复,您可以这样做。您将能够制作包含该消息的第二个tr
。然后,只有当$index
处于有效位置时,您才会显示它。
<tbody ng-repeat="iteam in items">
<tr>
<td>{{iteam}}</td>
<td class="main-row" ng-click=toggleDetails($index)>Click</td>
</tr>
<tr ng-show="activePosition == $index">
<td>{{message}}</td>
</tr>
</tbody>