朋友你好獲取打印,我在角js.I新需要幫助的打印分配給每一行按鍵的點擊每個 行的數據。以下是我的 代碼。在每一行上的點擊,相應行的數據應在角JS
HTML代碼:
- 列表項
在這裏輸入的代碼
<div class="jumbotron"> <table border='1'> <tr ng-show="reports.length!=0" ng-repeat="report in reports"> <td>{{report.first_name}}</td> <td>{{report.emp_id}}</td> <td>{{report.month_calendar_days}}</td> <td>{{report.pay_days}}</td> <td>{{report.paid_days}}</td> <td> 5" ng-repeat="key in noAlphabetSortPlease(report)" style="padding-left:10px;">{{report[key]}}</td> <td><button ng-click="PrintRow()">Print Row</button></td> </tr> </table> </div> </div>
控制器代碼:
angular.module( '應用',[])
.controller('mainController', ['$scope', '$filter', function($scope, $filter) { $scope.noAlphabetSortPlease = function(obj){ return Object.keys(obj); } $scope.reports = [{"emp_id":"10001","first_name":"siva","status":1,"month_calendar_days":29,"pay_days":29,"paid_days":21,"salary_head_value1":0,"salary_head_value2":7550,"salary_head_value3":1600,"salary_head_value4":1800,"salary_head_value5":345,"salary_head_value6":6400,"salary_head_value7":5000,"salary_head_value8":31955,"salary_head_value9":1250,"salary_head_value10":12000,"salary_head_value11":6000,"salary_head_value12":47900,"salary_head_value13":15945,"salary_head_value14":4000,"salary_head_value15":2400}, {"emp_id":"10002","first_name":"naren","status":1,"month_calendar_days":29,"pay_days":29,"paid_days":21,"salary_head_value1":15501,"salary_head_value2":7551,"salary_head_value3":1601,"salary_head_value4":1801,"salary_head_value5":346,"salary_head_value6":6401,"salary_head_value7":5001,"salary_head_value8":31957,"salary_head_value9":1251,"salary_head_value10":12001,"salary_head_value11":6001,"salary_head_value12":47907,"salary_head_value13":15950,"salary_head_value14":4001,"salary_head_value15":2401}, {"emp_id":"10003","first_name":"Bhaki","status":1,"month_calendar_days":29,"pay_days":29,"paid_days":21,"salary_head_value1":15502,"salary_head_value2":7552,"salary_head_value3":1602,"salary_head_value4":1802,"salary_head_value5":347,"salary_head_value6":6402,"salary_head_value7":5002,"salary_head_value8":31959,"salary_head_value9":1252,"salary_head_value10":12002,"salary_head_value11":6002,"salary_head_value12":47914,"salary_head_value13":15955,"salary_head_value14":4002,"salary_head_value15":2402}]; $scope.PrintRow=function($index){ window.print(); } }]); </script>
0
A
回答
2
將相應的對象傳遞給函數調用並覆蓋報告變量。
<tr ng-show="reports.length!=0" ng-repeat="report in reports">
<td>{{report.first_name}}</td>
<td>{{report.emp_id}}</td>
<td>{{report.month_calendar_days}}</td>
<td>{{report.pay_days}}</td>
<td>{{report.paid_days}}</td>
<td> 5" ng-repeat="key in noAlphabetSortPlease(report)" style="padding-left:10px;">{{report[key]}}</td>
<td><button ng-click="PrintRow(report)">Print Row</button></td>
</tr>
$scope.PrintRow=function(obj){
$scope.reports=[];
$scope.reports.push(obj);
}
,或者如果你希望所有的數據依然存在,要打印低於新的每一行的相應數據table.Then你可以做這樣的事情
<tr ng-show="reports.length!=0" ng-repeat="report in reports">
<td>{{report.first_name}}</td>
<td>{{report.emp_id}}</td>
<td>{{report.month_calendar_days}}</td>
<td>{{report.pay_days}}</td>
<td>{{report.paid_days}}</td>
<td> 5" ng-repeat="key in noAlphabetSortPlease(report)" style="padding-left:10px;">{{report[key]}}</td>
<td><button ng-click="PrintRow(report)">Print Row</button></td>
</tr>
{{newArray}}
$scope.newArray=[];
$scope.PrintRow=function(obj){
$scope.newArray.push(obj);
}
根據您的意願設置新數組。
<tr ng-show="reports.length!=0" ng-repeat="report in newArray">
<td>{{report.first_name}}</td>
<td>{{report.emp_id}}</td>
<td>{{report.month_calendar_days}}</td>
<td>{{report.pay_days}}</td>
<td>{{report.paid_days}}</td>
<td> 5" ng-repeat="key in noAlphabetSortPlease(report)" style="padding-left:10px;">{{report[key]}}</td>
<td><button ng-click="PrintRow(report)">Print Row</button></td>
</tr>
相關問題
- 1. 在tableview中點擊相應的行時獲取行數據
- 2. 如何在數據框的每一行上應用函數?
- 3. 在每個擊鍵上僅接受角度js上的整數和浮點數
- 4. 在角度js的每一行表中上傳文件
- 5. JS document.getElementById在Button上執行點擊
- 6. 角JS - 更新上點擊
- 7. jQuery在每個元素上只執行一次點擊函數?
- 8. 想要刪除相應的行上點擊刪除錨標記
- 9. 在點擊添加行到第一類和相應的<th>在表
- 10. 角2:刪除子組件上點擊相應的組件
- 11. 在每一行的多列上應用函數
- 12. 顯示上點擊相同的按鈕不同的div - 角JS
- 13. R在數據框的每一行和列中應用計算
- 14. 如何刪除按鈕點擊相應行的表格行?
- 15. jqGrid:從一個在一個角網格內點擊過的行獲取數據
- 16. jQuery的 - 計算點擊次數和執行相應
- 17. 如何在角js上查找標題上的點擊事件?
- 18. 執行不同的事件上第一和第二點擊角js
- 19. 點心領域,如果在相應的行中的另一列
- 20. 在Heroku上運行一個應用程序,但在別處的數據庫上運行一個應用程序
- 21. 在點擊測試,看看點擊了什麼,並相應地運行功能
- 22. 在SELECT語句的結果的每一行上應用代碼
- 23. 應用功能,每一行的每個字在大熊貓數據幀列
- 24. MySQL獲取行在同一表中存在相應的行
- 25. 每次點擊角
- 26. 點擊圖片並更新數據庫在軌道上的行
- 27. 如何在量角器頁面上每次點擊相同的分類元素
- 28. 如何在點擊角度上顯示不同的指令JS
- 29. .js文件每次點擊一個鏈接時執行
- 30. 點擊一個按鈕關閉在模擬器上運行的應用程序
您不需要ng-show,並且在ng-click上方的行看起來像缺少某些東西。 – rrd
嘗試用ng-repeat-start + ng-repeat-end – Plankton
這並不重要..我在每行添加了按鈕。當用戶單擊任意一行時,相應的行應該打印。 –