AngularJS API用于比较, 迭代和转换对象。基本AngularJS API包括
- angular.isString()
- angular.lowercase()
- angular.uppercase()
- angular.isNumber()
用于检查对象是否为字符串, 如果对象为字符串则返回true, 否则返回false。
例子:
<
!-- Write HTML code here -->
<
!DOCTYPE html>
<
html >
<
head >
<
script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js" >
<
/ script >
<
/ head >
<
body >
<
div ng-app = "gfg" ng-controller = "gfgCntrl" >
<
p >
{{ object }}<
/ p >
<
p >
{{ apiRes }}<
/ p >
<
/ div >
<
script >
var app = angular.module('gfg', []);
app.controller('gfgCntrl', function($scope) {
$scope.object = "lsbin";
$scope.apiRes = angular.isString($scope.object);
});
<
/ script >
<
/ body >
<
/ html >
输出如下:
2. angular.lowercase()
它用于将字符串的所有字符转换为小写字符。
例子:
<
!-- Write HTML code here -->
<
!DOCTYPE html>
<
html >
<
head >
<
script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js" >
<
/ script >
<
/ head >
<
body >
<
div ng-app = "gfg" ng-controller = "gfgCntrl" >
<
p >
{{ object }}<
/ p >
<
p >
{{ apiRes }}<
/ p >
<
/ div >
<
script >
var app = angular.module('gfg', []);
app.controller('gfgCntrl', function($scope) {
$scope.object = "lsbin";
$scope.apiRes = angular.lowercase($scope.object);
});
<
/ script >
<
/ body >
<
/ html >
输出如下:
3. angular.uppercase()
它用于将字符串的所有字符转换为大写字符。
例子:
<
!-- Write HTML code here -->
<
!DOCTYPE html>
<
html >
<
head >
<
script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js" >
<
/ script >
<
/ head >
<
body >
<
div ng-app = "gfg" ng-controller = "gfgCntrl" >
<
p >
{{ object }}<
/ p >
<
p >
{{ apiRes }}<
/ p >
<
/ div >
<
script >
var app = angular.module('gfg', []);
app.controller('gfgCntrl', function($scope) {
$scope.object = "lsbin";
$scope.apiRes = angular.uppercase($scope.object);
});
<
/ script >
<
/ body >
<
/ html >
输出如下:
4. angular.isNumber()
用于检查对象是否为数字。如果object是一个数字, 则返回true, 否则返回false。
例子:
<
!-- Write HTML code here -->
<
!DOCTYPE html>
<
html >
<
head >
<
script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js" >
<
/ script >
<
/ head >
<
body >
<
div ng-app = "gfg" ng-controller = "gfgCntrl" >
<
p >
{{ object }}<
/ p >
<
p >
{{ apiRes }}<
/ p >
<
/ div >
<
script >
var app = angular.module('gfg', []);
app.controller('gfgCntrl', function($scope) {
$scope.object = "lsbin";
$scope.apiRes = angular.isNumber($scope.object);
});
<
/ script >
<
/ body >
<
/ html >
【AngularJS API介绍和用法示例】输出如下:
推荐阅读
- AngularJS SQL介绍和用法示例
- 响应式设计(CSS媒体查询介绍和用法指南)
- 三星2021年暑期实习面试经历分享
- PHP如何使用dns_get_mx()函数()
- 如何将jQuery转换为JavaScript()
- 2017正版windows10企业版激活图文详细教程安装图文详细教程
- 本图文详细教程教你处理win10开机黑屏
- 电脑管家win10专版最新推荐
- 本图文详细教程教你微软官网win10专业版原版镜像地址