AngularJS 学习之表格
1.ng-repeat指令可以完美的显示表格;
2.在表格中显示数据:
<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>

3.使用CSS样式:
<style>
table,th,td{
border:1px solid grey;
border-collapse:collapse;
padding:5px;
}
table tr:nth-child(odd){
background-color:#f1f1f1;
}
table tr:nth-child(even){
background-color:#ffffff;
}
</style>
4.使用orderBy过滤器:排序显示,可以使用orderBy过滤器;
<table>
<tr ng-repeat="x in names | orderBy:'Country'">
<td>{{x.Name}}</td>
<td>{{x.Country}}</td>
</tr>
</table>

5.使用uppercase过滤器转换为大写:
<table>
<tr ng-repeat="x in names">
<td>{{x.Name}}</td>
<td>{{x.Country | uppercase }}</td>
</tr>
</table>

6.显示序号($index):表格显示序号可以在<td>中添加$index;
<table>
<tr ng-repeat="x in names">
<td>{{$index+1}}</td>
<td>{{x.Name}}</td>
<td>{{x.Country}}</td>
</tr>
</table>

7.使用$even和$odd:
<table>
<tr ng-repeat="x in names">
<td ng-if="$odd" style="background-color:#f1f1f1">{{x.Country}}</td>
<td ng-if="$even">{{x.Name}}</td>
<td ng-if="$odd" style="backgrund-color:#f1f1f1">{{x.Country}}</td>
<td ng-if="$even">{{x.Country}}</td>
</tr>
</table>

AngularJS 学习之表格的更多相关文章
- 《AngularJS学习整理》系列分享专栏
<AngularJS学习整理>系列分享专栏 <AngularJS学习整理>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/re ...
- Angularjs学习---官方phonecat实例学习angularjs step0 step1
接下来一系列的文章都是学习https://docs.angularjs.org/tutorial的笔记,主要学习的angular-phonecat项目的实现,来介绍angularjs的使用. 1.下载 ...
- angularJS学习资源最全汇总
基础 官方: http://docs.angularjs.org angularjs官方网站已被墙,可看 http://www.ngnice.com/: 官方zip下载包 https://github ...
- 我的AngularJS 学习之旅
我的AngularJS 学习之旅 基础篇 1.Angular的 起源 2.比较Web 页面实现的几种方式 3.一些基本术语 4.Angular与其他框架的兼容性 5.总结 6.综合实例 很早之前就 ...
- 推荐10个很棒的AngularJS学习指南
AngularJS 是非常棒的JS框架,能够创建功能强大,动态功能的Web app.AngularJS自2009发布以来,已经广泛应用于Web 开发中.但是对想要学习Angular JS 的人而言,只 ...
- Angularjs学习---ubuntu12.04中karma安装配置中常见的问题总结
karma启动时出现了很多问题: 1.安装karma前提条件 安装karma首先要安装nodejs,npm然后才可以安装karma.nodejs,npm的安装过程可以参考文章:Angularjs学习- ...
- AngularJs学习总结-了解基本特性(-)
现在的前端项目中基本上都会用到angularjs框架,之前并不了解这个框架,也是因为最近接手的项目,所以打算好好的学习下它.之前都是搞pc端,现在接手的是移动端的项目,移动端UI框架用的是ionic+ ...
- [整理]AngularJS学习资源
https://angular.io/docs/js/latest/(2.0官方网站) http://www.linuxidc.com/Linux/2014-05/102139.htm(Angular ...
- AngularJs学习笔记--Forms
原版地址:http://code.angularjs.org/1.0.2/docs/guide/forms 控件(input.select.textarea)是用户输入数据的一种方式.Form(表单) ...
随机推荐
- 问题 A: 【动态规划】采药_二维数组_一维数组
问题 A: [动态规划]采药 时间限制: 1 Sec 内存限制: 64 MB提交: 35 解决: 15[提交][状态][讨论版] 题目描述 山洞里有一些不同的草药,采每一株都需要一些时间,每一株也 ...
- validation验证器指定action中某些方法不需要验证
今天写代码时,遇到个问题,在一个输入数据的页面有一个按钮,单击会发出请求从数据库中取数据,在这里出现问题,单击该按钮,配置的validation起作用,该请求没有到达后台的action 点击按钮选择作 ...
- Qt 获取cmd运行结果
http://www.cnblogs.com/gisbeginner/archive/2012/12/08/2809063.html BOOL ExecDosCmd(){ #define EXECDO ...
- iOS应用架构谈(二):View层的组织和调用方案(中)
iOS客户端应用架构看似简单,但实际上要考虑的事情不少.本文作者将以系列文章的形式来回答iOS应用架构中的种种问题,本文是其中的第二篇,主要讲View层的组织和调用方案.中篇主要讨论MVC.MVCS. ...
- August 24th 2016 Week 35th Wednesday
Storms make trees take deeper roots. 暴风雨能使大树的根扎得更深. If the trees already have deep roots, then the s ...
- July 6th, Week 28th Wednesday, 2016
Diligence is the mother of good fortune. 勤勉是好运之母. The mother of good fortune can be diligence, conti ...
- Oulipo(poj 3461)
题意:求b这个字符串在a中出现的次数 这里不用KMP,用hash #include<cstdio> #include<iostream> #include<cstring ...
- 413. Arithmetic Slices
/**************************Sorry. We do not have enough accepted submissions.*********************** ...
- mySQL中如何给某一IP段的用户授权?
给一个用用户use ip: 192.168.0.1 语句是: grant all on *.* to root@192.168.0.1 identified by 'pass' 来授权 其中:root ...
- smarty汇总
Smarty:模板技术 实现功能:前后分离. 原理:主要通过Smarty核心类实现,调用display方法,将模板文件读取,用正则进行替换,替换完保存到临时文 件,将临时文件加载到当前页面. 配置文件 ...