扫码关注官方订阅号
如图:
上下两个都是数据表,如何实现呢?
业精于勤,荒于嬉;行成于思,毁于随。
给你个小例子玩玩看:jsfiddle
<p ng-controller="DemoCtrl"> <table border="1"> <tr ng-repeat="item in table1" ng-click="showDetail(item)"> <td>{{ item.id }}</td> <td>{{ item.name }}</td> <td>{{ item.age }}</td> </tr> </table> <table border="1"> <tr ng-repeat="item in table2"> <td>{{ item.address }}</td> <td>{{ item.email }}</td> </tr> </table> </p>
demo.controller('DemoCtrl', function($scope){ $scope.table2 = []; $scope.table1 = [ { id: 1, name: 'Hanmeimei', age: 31, detail: [{ address: 'Zhongguo', email: 'Hmm@sohu.com' }] },{ id: 2, name: 'Lilei', age: 32, detail: [{ address: 'Yindu', email: 'Ll@gmail.com' }] } ]; $scope.showDetail = function(item){ $scope.table2.length = 0; Array.prototype.push.apply($scope.table2, item.detail); }; });
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
给你个小例子玩玩看:jsfiddle