AngulerJS小知识点二

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

 

过滤器:{{name | uppercase}}数组

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

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

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

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

  

 <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的重复对象,能够用来建立一系列的对象元素。htm

<!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>
相关文章
相关标签/搜索