angular.isString()函数AngularJS中的ins用于确定isString函数内部的参数是否为字符串。如果引用是字符串, 则返回true, 否则返回false。
语法如下:
angular.isString( value )
返回值:如果传递的值是字符串, 则返回true, 否则返回false。
例子:本示例使用angular.isString()函数确定isString函数中的参数是否为字符串。
<!DOCTYPE html>
< html >
< head >
< title >angular.isString() function</ title >
< script src =
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js" >
</ script >
</ head >
< body ng-app = "app" style = "text-align:center" >
< h1 style = "color:green" >lsbin</ h1 >
< h2 >angular.isString()</ h2 >
< div ng-controller = "geek" >
< b >Input1: </ b >
< span >
< code >123</ code >
</ span >
< br >
< b >isString: </ b >{{isString1}}< br />< br >< br >
< b >Input2: </ b >
< code >
"lsbin"
</ code >
< br >
< b >isString:</ b > {{isString2}}
</ div >
<!-- Script to use angular.isString() function -->
< script >
var app = angular.module("app", []);
app.controller('geek', ['$scope', function ($scope) {
var obj1 = 123;
var obj2 = "lsbin";
$scope.isString1 = angular.isString(obj1);
$scope.isString2 = angular.isString(obj2);
}]);
</ script >
</ body >
</ html >
输出如下: