AngularJS教程
/ API
API
AngularJS 全局 API
AngularJS 全局 API 是一套全局 JavaScript 函數(shù),用于執(zhí)行一些常見(jiàn)的任務(wù),例如:
- 比較對(duì)象
- 迭代對(duì)象
- 轉(zhuǎn)換數(shù)據(jù)
全局 API 函數(shù)通過(guò)使用 angular 對(duì)象進(jìn)行訪(fǎng)問(wèn)。
下面是一些常用 API 函數(shù)的列表:
API | 描述 |
---|---|
angular.lowercase() | 將字符串轉(zhuǎn)換為小寫(xiě)。 |
angular.uppercase() | 將字符串轉(zhuǎn)換為大寫(xiě)。 |
angular.isString() | 如果引用是字符串,則返回 true。 |
angular.isNumber() | 如果引用是數(shù)字,則返回 true。 |
angular.lowercase() 示例
<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 = "BILL"; $scope.x2 = angular.lowercase($scope.x1); }); </script>運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線(xiàn)實(shí)例
angular.uppercase() 示例
<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 = "Bill"; $scope.x2 = angular.uppercase($scope.x1); }); </script>運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線(xiàn)實(shí)例
angular.isString() 示例
<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 = "BILL"; $scope.x2 = angular.isString($scope.x1); }); </script>運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線(xiàn)實(shí)例
angular.isNumber() 示例
<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 = "BILL"; $scope.x2 = angular.isNumber($scope.x1); }); </script>運(yùn)行實(shí)例 ?
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線(xiàn)實(shí)例