angular控制器

作用域

$rootScope 在聲明ng-app的位置創建此作用域

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" ng-app="myApp"> <!--<![endif]-->
<script src="./angular.min.js"></script>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
        <div ng-controller="myController">
            {{name}} 
        </div>
        {{name}} 
    </body>
    <script>
        var app = angular.module("myApp",[]);
        app.controller("myController",["$scope",function($scope){
            $scope.name = "zhar";
        }]);
    </script>
</html>
  • 同級的作用域,不可相互訪問。
  • 子集能夠訪問父集的變量。
  • 子集作用域能夠訪問使用父集作用域的值,但無權修改。

過濾器

currency 貨幣格式轉換
currency:“前綴” 更改指定的前綴,默認是$
lowercase | uppercase 大小寫轉換
date 日期格式化
數組過濾器
limitTo 限制結果條數
orderBy 排序
orderBy:orderKey 按orderKey升序排列
orderBy:orderKey:true 按orderKey降序排列
filter 按關鍵字快速過濾
filter:searchKey 過濾所以數據包含 searchKey的內容

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容