AngularJS – isUndefined() method

The isUndefined() method in AngularJS basically checks if a reference is defined or not. This method will return True if the reference passed inside the function is not defined or undefined, else it will return False.

Syntax

angular.isUndefined(value)

Example − Check if the reference isUndefined or not

Create a file "isUndefined.html.3" in your Angular project directory and copy-paste the following code snippet.


   
      angular.isUndefined()

      
   

   
      

         Welcome to Tutorials Point      

     

AngularJS | angular.isUndefined()

     
         Name: {{name}}          

         {{isUndefined}}          

         Name: {{name2}}          

         {{isUndefined1}}      
           

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

In the code, $scope.name is defined, whereas $scope.name2 is not undefined. Hence, we got this output.

Updated on: 2021-10-08T10:48:32+05:30

536 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements