AngularJS中的API(接口)簡單實(shí)現(xiàn)
AngularJS API
API 意為 Application Programming Interface(應(yīng)用程序編程接口)。
AngularJS 全局 API
AngularJS 全局 API 用于執(zhí)行常見任務(wù)的 JavaScript 函數(shù)集合,如:
比較對象
迭代對象
轉(zhuǎn)換對象
全局 API 函數(shù)使用 angular 對象進(jìn)行訪問。
以下列出了一些通用的 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>
運(yùn)行結(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>
運(yùn)行結(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>
運(yùn)行結(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>
運(yùn)行結(jié)果:
JOHN
false
以上就是對AngularJS API(接口)資料的整理,后續(xù)繼續(xù)補(bǔ)充,希望能幫助編程的同學(xué)。
相關(guān)文章
Angular中自定義Debounce Click指令防止重復(fù)點(diǎn)擊
本篇文章主要介紹了Angular中自定義Debounce Click指令詳解,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07AngularJS利用Controller完成URL跳轉(zhuǎn)
本文的主要內(nèi)容是介紹在AngularJS中怎樣利用Controller實(shí)現(xiàn)URL跳轉(zhuǎn),本文給出了實(shí)例代碼,簡單明了,有需要的可以參考學(xué)習(xí)。2016-08-08Angular實(shí)踐之將Input與Lifecycle轉(zhuǎn)換成流示例詳解
這篇文章主要為大家介紹了Angular實(shí)踐之將Input與Lifecycle轉(zhuǎn)換成流示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02詳解Angular的內(nèi)置過濾器和自定義過濾器【推薦】
在實(shí)際的開發(fā)過程中,很多后端返回給我們的數(shù)據(jù)都是需要格式化處理的,在angular中為我們內(nèi)置提供了filter指令,可以很方便的對數(shù)據(jù)進(jìn)行處理。本文將對Angular的內(nèi)置過濾器和自定義過濾器進(jìn)行詳細(xì)介紹,下面跟著小編一起來看下吧2016-12-12Angular進(jìn)行簡單單元測試的實(shí)現(xiàn)方法實(shí)例
這篇文章主要給大家介紹了關(guān)于Angular進(jìn)行簡單單元測試的實(shí)現(xiàn)方法,文中僅用了幾行代碼,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Angular具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08Angular中ng?update命令force參數(shù)含義詳解
這篇文章主要為大家介紹了Angular中ng?update命令force參數(shù)含義詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10詳解Angular.js的$q.defer()服務(wù)異步處理
相信大家都知道jquery和angular都有defer服務(wù),這篇文章暫以angular為例談?wù)剛€(gè)人的理解,在文章的最后并附上jquery的阮一峰總結(jié)的defer。有需要的朋友們也可以參考借鑒,下面來一起學(xué)習(xí)學(xué)習(xí)吧。2016-11-11關(guān)于angularJs指令的Scope(作用域)介紹
下面小編就為大家?guī)硪黄猘ngularJs指令的Scope(作用域)介紹。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-10