AngularJS中的API(接口)簡單實現(xiàn)
AngularJS API
API 意為 Application Programming Interface(應用程序編程接口)。
AngularJS 全局 API
AngularJS 全局 API 用于執(zhí)行常見任務的 JavaScript 函數(shù)集合,如:
比較對象
迭代對象
轉(zhuǎn)換對象
全局 API 函數(shù)使用 angular 對象進行訪問。
以下列出了一些通用的 API 函數(shù):
| API | 描述 |
|---|---|
| angular.lowercase() | 轉(zhuǎn)換字符串為小寫 |
| angular.uppercase() | 轉(zhuǎn)換字符串為大寫 |
| angular.isString() | 判斷給定的對象是否為字符串,如果是返回 true。 |
| angular.isNumber() | 判斷給定的對象是否為數(shù)字,如果是返回 true。 |
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>
運行結(jié)果:
JOHN
john
angular.uppercase()
<!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.isString($scope.x1);
});
</script>
</body>
</html>
運行結(jié)果:
JOHN
true
angular.isString()
<!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.isString($scope.x1);
});
</script>
</body>
</html>
運行結(jié)果:
JOHN
true
angular.isNumber()
<!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.isNumber($scope.x1);
});
</script>
</body>
</html>
運行結(jié)果:
JOHN
false
以上就是對AngularJS API(接口)資料的整理,后續(xù)繼續(xù)補充,希望能幫助編程的同學。
相關文章
Angular中自定義Debounce Click指令防止重復點擊
本篇文章主要介紹了Angular中自定義Debounce Click指令詳解,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07
AngularJS利用Controller完成URL跳轉(zhuǎn)
本文的主要內(nèi)容是介紹在AngularJS中怎樣利用Controller實現(xiàn)URL跳轉(zhuǎn),本文給出了實例代碼,簡單明了,有需要的可以參考學習。2016-08-08
Angular實踐之將Input與Lifecycle轉(zhuǎn)換成流示例詳解
這篇文章主要為大家介紹了Angular實踐之將Input與Lifecycle轉(zhuǎn)換成流示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-02-02
詳解Angular的內(nèi)置過濾器和自定義過濾器【推薦】
在實際的開發(fā)過程中,很多后端返回給我們的數(shù)據(jù)都是需要格式化處理的,在angular中為我們內(nèi)置提供了filter指令,可以很方便的對數(shù)據(jù)進行處理。本文將對Angular的內(nèi)置過濾器和自定義過濾器進行詳細介紹,下面跟著小編一起來看下吧2016-12-12
Angular中ng?update命令force參數(shù)含義詳解
這篇文章主要為大家介紹了Angular中ng?update命令force參數(shù)含義詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-10-10

