AngularJS入门教程之表格实例详解(3)

1   Alfreds Futterkiste   Germany  
2   Ana Trujillo Emparedados y helados   Mexico  
3   Antonio Moreno Taquería   Mexico  
4   Around the Horn   UK  
5   B's Beverages   UK  
6   Berglunds snabbköp   Sweden  
7   Blauer See Delikatessen   Germany  
8   Blondel père et fils   France  
9   Bólido Comidas preparadas   Spain  
10   Bon app'   France  
11   Bottom-Dollar Marketse   Canada  
12   Cactus Comidas para llevar   Argentina  
13   Centro comercial Moctezuma   Mexico  
14   Chop-suey Chinese   Switzerland  
15   Comércio Mineiro   Brazil  

使用 $even 和 $odd

AngularJS 实例

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> <style> table, td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } </style> </head> <body> <div ng-app="myApp" ng-controller="customersCtrl"> <table> <tr ng-repeat="x in names"> <td ng-if="$odd"> {{ x.Name }}</td> <td ng-if="$even"> {{ x.Name }}</td> <td ng-if="$odd"> {{ x.Country }}</td> <td ng-if="$even"> {{ x.Country }}</td> </tr> </table> </div> <script> var app = angular.module('myApp', []); app.controller('customersCtrl', function($scope, $http) { $http.get("/try/angularjs/data/Customers_JSON.php") .success(function (response) {$scope.names = response.records;}); }); </script> </body> </html>

运行效果:

Alfreds Futterkiste   Germany  
Ana Trujillo Emparedados y helados   Mexico  
Antonio Moreno Taquería   Mexico  
Around the Horn   UK  
B's Beverages   UK  
Berglunds snabbköp   Sweden  
Blauer See Delikatessen   Germany  
Blondel père et fils   France  
Bólido Comidas preparadas   Spain  
Bon app'   France  
Bottom-Dollar Marketse   Canada  
Cactus Comidas para llevar   Argentina  
Centro comercial Moctezuma   Mexico  
Chop-suey Chinese   Switzerland  
Comércio Mineiro   Brazil  

以上就是对AngularJS 表格资料的整理,后续继续补充,希望能帮助到有需要的同学。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzxpzj.html