AngularJS Table

<div ng-app="myApp" ng-controller="customersCtrl">
  <table>
       <tr ng-repeat="x in names">
             <td>{{ x.name }}</td>
              <td>{{ x.age }}</td>
        </tr>
   </table>
</div>
<script>
  var app=angular.module("myApp",[]);
   app.controller("customersCrtl",function($scope,$http)
   {
             $http.get("http:127.1.0.1/myweb/index.aspx").success(function(response)
                  {
                        $scope.names=response.records;

                   })

 });

</script>

添加样式:

<style>

        table,th,td{

              border:1px solid grey;

              border-collapse:collapse;

              padding:5px;

            }
          table tr:nth-child(odd){

              background-color:#flflfl;

             }

           table tr:nth-child(even){

              background-color:#ffffff;

              }

</style>

用orderBy过滤器:

<table>

     <tr ng--repeat="x in names|orderBy:age">

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

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

      </tr>

</table>

用uppercase和lowercase过滤器:

<table>
  <tr ng-repeat="x in names">
           <td>{{ x.name |lowercase}}</td>
            <td>{{ x.age|uppercase }}</td>
   </tr>

</table>

在表格中显示序号:$index+1

<table>
      <tr ng-repeat="x in names">
           <td>{{$index+1}}</td>
            <td>{{x.name}}</td>
            <td>{{x.age}}</td>
         </tr>
</table>

使用$even和$odd

 <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.age}}</td>
     <td ng-if="$even">{{x.age}}</td>
    </tr></table>

摘录自runoob.com。旨在通过自己的语言加深对AngularJS的学习、理解和记忆。

时间: 2024-10-25 08:11:19

AngularJS Table的相关文章

Angularjs bootstrap table多选(全选),支持单击行选中

最终实现效果:  index.html <!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-anima

table sorting&ndash;angularjs

1: <script type="text/javascript" ng:autobind 2: src="http://code.angularjs.org/0.10.5/angular-0.10.5.js"></script> 3:   4: <table ng:controller="SortableTableCtrl"> 5: <thead> 6: <tr> 7: <th

Part 10 AngularJS sort rows by table header

Here is what we want to do 1. The data should be sorted when the table column header is clicked 2. The user should be able to sort in both the directions - ascending and descending. Clicking on the column for the first time should sort the data in as

[转]AngularJS 实现 Table的一些操作(示例大于实际)

本文转自:http://www.cnblogs.com/lin-js/p/linJS.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="lib/angular.js"></script> <style type="text/

Node.js 使用angularjs取得Nodejs http服务端返回的JSON数组示例

server.js代码: // 内置http模块,提供了http服务器和客户端功能(path模块也是内置模块,而mime是附加模块) var http=require("http"); // 创建服务器,创建HTTP服务器要调用http.createServer()函数,它只有一个参数,是个回调函数,服务器每次收到http请求后都会调用这个回调函数.服务器每收到一条http请求,都会用新的request和response对象触发请求函数. var server=http.createS

AngularJS 学习笔记(四)

用AngularJS实现购物车,具体代码如下: <!DOCTYPE html> <html ng-app="app"> <head>     <meta charset="utf-8">     <link href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"

使用angularjs对数据进行排序筛选

看下面的代码 scope.Person = [ {'id':1,'name':'小张','age':18}, {'id':2,'name':'Tom','age':19}, {'id':3,'name':'张三','age':19}, {'id':4,'name':'小明','age':17} ]; 这儿有一个对象数组,在angularjs控制器里写的,把它显示在页面上的时候可以对其进行排序和筛选. <table> <tr> <th>编号</th> <

AngularJS自整理

准备: 从该地址获取AngularJS所以版本: https://code.angularjs.org/ 1.初时AngularJS 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <script src="../angular.m

AngularJS 最常用的八种功能

第一 迭代输出之ng-repeat标签ng-repeat让table ul ol等标签和js里的数组完美结合<ul><li ng-repeat="person in persons">{{person.name}} is {{person.age}} years old.</li></ul>你甚至可以指定输出的顺序:<li ng-repeat="person in persons | orderBy:'name'"