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. python - django中找不到css等靜態文件2. python - 爬取微信公眾號文章需要輸入驗證碼問題3. mysql - 10g數據庫如何遷移4. mysql多表聯合查詢優化的問題5. python - 調用api輸出頁面,會有標簽出現,請問如何清掉?6. javascript - vue引入微信jssdk 配置在哪個生命周期調取接口配置?7. node.js - session怎么存到cookie,然后服務器重啟后還能獲取。數據庫不用mongodb或redis,數據庫是mysql8. 數據庫設計 - 社交應用的mysql表主鍵該怎么定義?9. mysql - 對單表大量數據進行報表匯總有什么高效的方法10. python 匹配數據輸出數據
