AngularJS angular.isUndefined() 函数
AngularJS angular.isUndefined() 函数,AngularJS 中的angular.isUndefined() 函数用于判断参数是否未定义。如果参数未定义,则返回 true,否则返回 false。
语法:
angular.isUndefined( value )
返回值:如果传递的值未定义,则返回true,否则返回false。
示例:使用 angular.isUndefined() 函数来确定参数是否未定义。
<!DOCTYPE html>
<html>
<head>
<title>angular.isUndefined() 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">GeeksforGeeks</h1>
<h2>angular.isUndefined()</h2>
<div ng-controller="isDefinedController">
<b>Date:</b> {{date}}<br><br>
{{isUndefined}}
<br><br><br>
<b>Date1:</b> {{date1}}<br><br>
{{isUndefined1}}
</div>
<!-- Script to uses angular.isUndefined() function -->
<script>
var app = angular.module("app", []);
app.controller('isDefinedController',
['$scope', function ($scope) {
$scope.date = new Date;
$scope.date1;
$scope.isUndefined = angular.isUndefined($scope.date)
== true ? "$scope.date is Undefined."
: "$scope.date is not Undefined.";
$scope.isUndefined1 = angular.isUndefined($scope.date1)
== true ? "$scope.date1 is Undefined."
: "$scope.date1 is not Undefined.";
}]);
</script>
</body>
</html>
输出:
常见问题FAQ
- 程序仅供学习研究,请勿用于非法用途,不得违反国家法律,否则后果自负,一切法律责任与本站无关。
- 请仔细阅读以上条款再购买,拍下即代表同意条款并遵守约定,谢谢大家支持理解!