The Wayback Machine - https://web.archive.org/web/20240928070508/https://www.geeksforgeeks.org/angularjs-angular-isundefined-function/
Open In App

AngularJS angular.isUndefined() Function

Last Updated : 08 Nov, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 )

Parameter value:

  • value: It is used to reference the value to check whether the value is defined or undefined.

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

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

HTML




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

 

Example 2:  This example uses angular.isUndefined() function in AngularJS by verifying the defined & undefined values.

HTML




<!DOCTYPE html>
<html>
  
<head>
      <title>angular.isUndefined() function</title>
    <script src=
    </script>
    <style>
        body {
            text-align: center;
            font-family: 'Times New Roman', Times, serif;
        }
  
        h1 {
            color: green;
        }
    </style>
</head>
  
<body ng-app="App">
    <h1>GeeksforGeeks</h1>
    <h3>angular.isUndefined() Function</h3>
    <div ng-controller="geek">
        First value is {{displayVal1}}<br>
        Second value is {{displayVal2}}<br><br>
        <input type="button" 
               ng-click="Check()" 
               value="Check Value">
    </div>
    <script>
        var App = angular.module("App", []);
        App.controller("geek", function ($scope) {
            var val1 = "GeeksforGeeks";
            var val2;
            $scope.displayVal1 = '';
            $scope.displayVal2 = '';
            $scope.Check = function () {
                angular.isUndefined(val1)? $scope.displayVal1 = 
                'does not exist': $scope.displayVal1 = 'Exist';
                angular.isUndefined(val2)? $scope.displayVal2 = 
                'does not exist' : $scope.displayVal2 = 'Exist';
            }
        });
    </script>
</body>
</html>


Output:

 



Previous Article
Next Article

Similar Reads

Underscore.js _.isUndefined() Function
_.isUndefined() function: It checks if the parameter passed to it is undefined or not. If the parameter passed is undefined the it return true otherwise it returns false. We can even pass window elements to it. Syntax:_.isUndefined(value) Parameters:It takes only one argument which is the value or the variable that needs to be checked. Return value
2 min read
Lodash _.isUndefined() Method
Lodash _.isUndefined() method is used to find whether the given value is undefined or not. It returns True if the given value is undefined. Otherwise, it returns false. Syntax:_.isUndefined(value);Parameters:value: This parameter holds the value to check.Return Value:This method returns true if the value is undefined, else false. Example 1: In this
1 min read
AngularJS angular.isObject() Function
The angular.isobject() Function in AngularJS is used to determine if the parameter inside isobject function is an object or not. It returns true if the reference is an object or else false. Syntax: angular.isobject(value);Parameter: value: This parameter value validates whether the entered value is an object or not.Return Value: It returns true if
2 min read
AngularJS angular.isNumber() Function
The angular.isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false. Syntax: angular.isNumber( value );Parameter value: value: It determines whether the entered value is a number or not.Return Value: It returns a boolean val
2 min read
AngularJS | angular.isString() Function
The angular.isString() function in AngularJS is used to determine the parameter inside isString function is a string or not. It returns true if the reference is a string otherwise returns false. Syntax: angular.isString( value ) Return Value: It returns true if the value passed is a string otherwise return false. Example: This example uses angular.
1 min read
AngularJS angular.isDefined() Function
The angular.isDefined() function in AngularJS is used to determine the value inside isDefined function is defined or not. It returns true if the reference is defined otherwise returns false. Syntax: angular.isDefined( value );Parameter value: value: This parameter is a reference to check whether the entered value is defined or not.Return Value: It
2 min read
AngularJS angular.isDate() Function
The angular.isDate() function in AngularJS is used to determine whether the value of the date is valid or not. It returns true if the reference is a date else false. Syntax: angular.isDate( value );Parameters: This function accepts a single parameter: value: It stores the data object. Return Value: It returns true if the value passed is a date else
2 min read
AngularJS angular.toJson() Function
The angular.toJson() Function in AngularJS is used to serialize the javascript object into a JSON - formatted string. It takes the javascript object and returns a JSON string. The angular.toJson() function in AngularJS is capable of handling circular references in JavaScript objects. Circular references occur when an object refers to itself or when
2 min read
AngularJS angular.element() Function
The angular.element() Function in AngularJS is used to initialize DOM element or HTML string as an jQuery element. If jQuery is available angular.element can be either used as an alias for the jQuery function or it can be used as a function to wrap the element or string in Angular's jqlite. Syntax: angular.element(element)Parameter value: element:
2 min read
AngularJS angular.isFunction() Function
The angular.isFunction() Function in AngularJS is used to determine if the parameter inside isFunction function is a function or not. It returns true if the reference is a function else false. Syntax: angular.isFunction(value);Parameter: value: This parameter specifies whether the passed value is a function or not.Return Value: It returns true if t
2 min read
AngularJS angular.isElement() Function
The angular.isElement() Function in AngularJS is used to determine if the parameter inside isElement function is a HTML DOM element or not. It returns true if the reference is a DOM element or else false. Syntax: angular.isElement(value)Parameter: value: It is used to validate whether the passed argument is an HTML DOM element or not.Return Value:
2 min read
AngularJS angular.equals() Function
The angular.equals() Function in AngularJS is used to compare two objects or two values whether these are the same or not. If the two values are the same, it returns TRUE else it will return FALSE. The angular.equals() Function supports value types, regular expressions, arrays and objects. Syntax: angular.equals(val1, val2);Parameter value: val1
2 min read
AngularJS angular.isArray() Function
The angular.isArray() Function in AngularJS is used to return TRUE if the reference is an array and FALSE if it is not an array. Syntax: angular.isArray(value);Parameter: value: It specifies the reference to check the value.Return value: Returns TRUE if the value is an array else it will return FALSE. Example 1: This example describes the basic usa
2 min read
AngularJS angular.bind() Function
The angular.bind() Function in AngularJS is used to bind the current context to a function, but actually, execute it at a later time. It can also be used in Partial Applications. Partial Application is when you want to make a function but some of the arguments have been passed already. Syntax: angular.bind(self, function, args);Parameter Values: se
2 min read
AngularJS angular.bootstrap() Function
The angular.bootstrap() Function in AngularJS is a functional component in the Core ng module which is used to start up an Angular application manually, it provides more control over the initialization of the application. Syntax: angular.bootstrap(element, [modules], [config]);Parameter Values: element: An element is a DOM element (e.g. document) t
2 min read
AngularJS angular.forEach() Function
The angular.forEach() Function in AngularJS is used to iterate through each item in an array or object. It works similar to the for loop and this loop contains all properties of an object in key-value pairs of an object. Syntax: angular.forEach(object, iterator, [context])Parameter Values: object: It refers to the object to be iterated.iterator: It
1 min read
AngularJS angular.lowercase() Function
The angular.lowercase() Function in AngularJS is used to convert the string into lowercase. It can be used when the user wants to show the text in lowercase instead of uppercase or one wants to compare two strings. Syntax: angular.lowercase(string)Example 1: This example describes the implementation of the angular.lowercase() Function in AngularJS
2 min read
AngularJS angular.uppercase() Function
The angular.uppercase() Function in AngularJS is used to convert the string into uppercase. It can be used when the user wants to show the text in uppercase instead of lowercase. Syntax: angular.uppercase(string)Example: This example illustrates the angular.uppercase() Function by specifying the string is converted into uppercase. C/C++ Code <!D
2 min read
Difference between AngularJS Expression and Angular Expression
AngularJS is a JavaScript-based framework that can be used by adding it to an HTML page using a <script> tag. AngularJS helps in extending the HTML attributes with the help of directives and binding of data to the HTML with expressions. Angular on the other hand is a client-side TypeScript-based, front-end web framework by Google. Angular is
3 min read
Difference Between Angular and AngularJS
Angular and AngularJS are two popular frameworks used for building dynamic web applications. While both are developed by Google, they are fundamentally different in terms of architecture, features, and performance. AngularJS, released in 2010, is the older, JavaScript-based version, while Angular, introduced in 2016, is a complete rewrite using Typ
5 min read
How to execute AngularJS controller function on page load ?
In this article, we will see how to execute/call a JS function on page load using AngularJS. This function can be used to perform initialization. Calling a function or initializing a single value on page load in AngularJS is quite easy. AngularJS provides us with a dedicated directive for this specific task. It's the ng-init directive. Syntax: <
2 min read
How to use javascript function in string interpolation in AngularJS ?
String interpolation is basically used to display the dynamic data on an HTML template. It facilitates you to make changes on component.ts file and automatically fetch data from there to the HTML template (component.html file). So here we create a simple HTML template that uses the string interpolation, and then we write the function that is used i
2 min read
AngularJS Function Complete Reference
Functions in AngularJS are used to perform some frequent tasks or clarify something. For example AngularJS angular.isArray() function is used to verify that the assigned object is an array or not. AngularJS Converting Functions:Function Description AngularJS angular.lowercase() Function The angular.lowercase() Function in AngularJS is used to conve
2 min read
How to call an AngularJS Function inside HTML ?
A Function is a set of statements that takes input, does some specific computation, and produces output. In this article, we will learn How to Call an AngularJS function inside HTML. To achieve this, we can use {{...}} to call the function from HTML. We can also pass arguments and return the result back to HTML. Steps for Installing & Configuri
3 min read
How to access the Scope from outside JS Function in AngularJS ?
In the AngularJS application, we generally need to access the scope from the outside JS function. This can be done using the global scope object like $rootScope or the AngularJS services. Accessing the scope from the outside of JS functions is to enable the manipulation of data in the scope of the application in response to user actions. In this ar
4 min read
Routing in Angular JS using Angular UI Router
AngularJS is a front-end web application framework based on JavaScript and is maintained by Google. AngularJS interprets the attributes of HTML as directives to bind input/output components to a model represented by standard JavaScript variables. Pre-requisites: HTML CSS JavaScript AngularJS Angular-UI-Router is an AngularJS module used to create r
3 min read
Angular 7 | Angular Data Services using Observable
Observables Observable manage async data and a few other useful patterns. Observables are similar to Promises but with a few key differences. Unlike Promises, Observables emit multiple values over time. In real scenarios, web socket or real-time based data or event handlers can emit multiple values over any given time. In such a case Observables ar
4 min read
Adding Angular Material Component to Angular Application
Angular Material provides Design Components for Angular. This is build and maintained by Angular Team. This provides the Angular developers with common UI components and tools to help build their own custom components. We as a user can integrate this with our Angular Application using the npm packages provided by them. Angular Material also provide
2 min read
Difference between Angular 4 and Angular 5
Angular 4: Angular 4 was launched 5 years after the official release of AngularJS. Angular 4 is a JavaScript-based open-source framework for building web applications in JavaScript, HTML, and TypeScript, which is a superset of JavaScript. Angular 4 was launched in the March 2017 and supports earlier TypeScript versions such as TypeScript 2.2 and 2.
2 min read
Angular Cheat Sheet - A Basic Guide to Angular
Angular is a client-side TypeScript-based, front-end web framework developed by the Angular Team at Google, that is mainly used to develop scalable single-page web applications(SPAs) for mobile & desktop. Angular is a great, reusable UI (User Interface) library for developers that helps in building attractive, steady, and utilitarian web pages
15+ min read