您的位置:首页 > Web前端 > AngularJS

angular-表格

2016-03-22 22:54 525 查看
ng-repeat 指令可以完美的显示表格。

<div ng-app="myApp" ng-controller="customersCtrl">


<table>

<tr ng-repeat="x in names">

<td>{{ x.Name }}</td>

<td>{{ x.Country }}</td>

</tr>

</table>


</div>


<script>

var app = angular.module('myApp', []);

app.controller('customersCtrl', function($scope, $http) {

$http.get("http://www.runoob.com/try/angularjs/data/Customers_JSON.php")

.success(function (response) {$scope.names = response.records;});

});

</script>

[/code]
<table>

<tr ng-repeat="x in names">

<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Name }}</td>

<td ng-if="$even">{{ x.Name }}</td>

<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.Country }}</td>

<td ng-if="$even">{{ x.Country }}</td>

</tr>

</table>

[/code]
这个$odd$even是什么意思?

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: