AngularJS API

API 意为 Application Programming Interface(应用程序编程接口)。

AngularJS 全局 API

AngularJS 全局 API 用于执行常见任务的 JavaScript 函数集合,如:

  • 比较对象
  • 迭代对象
  • 转换对象

全局 API 函数使用 angular 对象进行访问。

以下列出了一些通用的 API 函数:

angular.lowercase()

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
    </head>
    <body>
        <div ng-app="myApp" ng-controller="myCtrl">
            <p>{{ x1 }}</p>
            <p>{{ x2 }}</p>
        </div>
        <script>
            var app = angular.module('myApp', []);
            app.controller('myCtrl', function($scope) {
                $scope.x1 = "JOHN";
                $scope.x2 = angular.lowercase($scope.x1);
            });
        </script>
    </body>
</html>

angular.uppercase()

$scope.x1 = "John";
$scope.x2 = angular.uppercase($scope.x1);

angular.isString()

$scope.x1 = "JOHN";
$scope.x2 = angular.isString($scope.x1); //true

angular.isNumber()

$scope.x1 = "JOHN";
$scope.x2 = angular.isNumber($scope.x1);//false

原文地址:https://www.cnblogs.com/chrisghb8812/p/5674111.html