angular.js - angular如何实现一个界面两个table模块并存呢?
问题描述
如图:
上下两个都是数据表,如何实现呢?
问题解答
回答1:给你个小例子玩玩看: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); };});
相关文章:
1. javascript - 微信小程序 如何实现这种左滑动出现删除的办法?有相关api吗?2. python打开.py文件的时候出现window无法打开该文件是怎么回事呢?3. javascript - vue中input的blur影响了下拉的点击事件如何解决4. dockerfile - 为什么docker容器启动不了?5. javascript - swiper插件loop模式下的BUG?6. docker gitlab 如何git clone?7. docker 17.03 怎么配置 registry mirror ?8. mysql插入文本如果是个sql语句就报错了9. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””10. javascript - sublime快键键问题

网公网安备