isUndefined() AngularJS의 메소드는 기본적으로 참조가 정의되었는지 여부를 확인합니다. 이 메서드는 함수 내부에 전달된 참조가 정의되지 않았거나 정의되지 않은 경우 True를 반환하고, 그렇지 않으면 False를 반환합니다.
구문
angular.isUndefined(value)
예 - 참조가 정의되지 않았는지 확인
"isUndefined.html.3 파일 생성 " Angular 프로젝트 디렉토리에 다음 코드 스니펫을 복사하여 붙여넣습니다.
<!DOCTYPE html>
<html>
<head>
<title>angular.isUndefined()</title>
<script src= "https://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">
Welcome to Tutorials Point
</h1>
<h2>AngularJS | angular.isUndefined()</h2>
<div ng-controller="example">
<b>Name: {{name}}</b>
<br><br>
{{isUndefined}}
<br><br>
<b>Name: {{name2}}</b>
<br><br>
{{isUndefined1}}
</div>
<!-- Script for passing the values and checking... -->
<script>
var app = angular.module("app", []);
app.controller('example',['$scope', function ($scope)
{
// Defining the keys & values
$scope.name = "SIMPLY LEARNING";
$scope.name2;
$scope.isUndefined = angular.isUndefined($scope.name) == true
? "$scope.name is Undefined."
: "$scope.name is Defined.";
$scope.isUndefined1 = angular.isUndefined($scope.name2)== true
? "$scope.name2 is Undefined."
: "$scope.name2 is Defined.";
}]);
</script>
</body>
</html> 출력
위의 코드를 실행하려면 파일로 이동하여 일반 HTML 파일로 실행하면 됩니다. 브라우저 창에 다음과 같은 출력이 표시됩니다.

코드에서 $scope.name $scope.name2 정의되지 않았습니다. 따라서 우리는 이 결과를 얻었습니다.