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>
相關文章
相關標籤/搜索