Skip to content
Related Articles

Related Articles

AngularJS | angular.isUndefined() Function
  • Last Updated : 12 Apr, 2019

The angular.isUndefined() function in AngularJS is used to determine the value inside isUndefined function is undefined or not. It returns true if the reference is undefined otherwise returns false.

Syntax:

angular.isUndefined( value )

Return Value: It returns true if the value passed is undefined else returns false.

Example: This example uses angular.isUndefined() function to determine the value inside isUndefined function is undefined or not.




<!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>

Output:
isUndefined




My Personal Notes arrow_drop_up
Recommended Articles
Page :