AngulerJS小知识点二

AngularJS与其他JavaScript框架最主要的区别在于,控制器并不合适用来执行DOM操作、格式化或数据操作,以及除存储数据模型以外的状态维护操作。他只是视图和$scope之间的桥梁。

过滤器:{{name | uppercase}}

1.currency---->将一个数值格式化为货币格式。

2.date---->将日期格式化为所需格式。

3.filter---->从给定数组中选择一个子集,并将其生成一个新的数组返回。

4.limitTo---->根据传入的参数生成一个新的数组或字符串,

  

 <label>{{money | currency:$}}</label>
  <label>{{time | date:"yyyy-MM-dd"}}</label>
 <!--排序-->
  <select ng-model="orderText">
     <option value="age">年龄升序</option>
      <option value="-age">年龄降序</option>
  </select>

ng-repeat是一个angular的重复对象,可以用来创建一系列的对象元素。

<!DOCTYPE html>
<html ng-app>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="js/angular.min.js"></script>
    <script>
        function StudentController($scope){
            $scope.students = [
                {id:1,name:"张飞",sex:"",age:20,phone:12345},
                {id:1,name:"关羽",sex:"",age:21,phone:12345},
                {id:1,name:"刘备",sex:"",age:22,phone:12345}
            ];
        }
    </script>
</head>
<body>
    <div ng-controller="StudentController">
        <table>
            <tr ng-repeat="student in students">
                <td>{{student.name}}</td>
                <td>{{student.sex}}</td>
                <td>{{student.age}}</td>
                <td>{{student.phone}}</td>
            </tr>
        </table>
    </div>
</body>
</html>
原文地址:https://www.cnblogs.com/yin-yi/p/4697030.html