您的位置:首頁技術文章
文章詳情頁

angular.js - angular如何實現一個界面兩個table模塊并存呢?

瀏覽:142日期:2024-10-02 09:58:01

問題描述

如圖: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); };});

相關文章:
国产综合久久一区二区三区