AngularJS | angular.isUndefined() Function

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
isUndefined



My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.