GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • AngularJS Tutorial
  • Interview Questions
  • Examples
  • Cheat Sheet
  • JavaScript
  • Web Technology
  • Directives
  • Functions
  • AngularJS Filters
  • Angular ngx Bootstrap
  • AngularJS PrimeNG
  • AngularJS Introduction4 min read
  • Angular CLI | Angular Project Setup3 min read
  • AngularJS Expressions2 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — AngularJS angular.isDefined() Function - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • AngularJS Tutorial
  • Interview Questions
  • Examples
  • Cheat Sheet
  • JavaScript
  • Web Technology
  • Directives
  • Functions
  • AngularJS Filters
  • Angular ngx Bootstrap
  • AngularJS PrimeNG

AngularJS angular.isDefined() Function

Last Updated : 6 Sep, 2022

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 returns true if the passed value is defined otherwise returns false. 

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

HTML
<!DOCTYPE html>
<html>

<head>
    <title>angular.isDefined()</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>
    <h3>angular.isDefined()</h3>
    <div ng-controller="geek">
        <b>Date:</b> {{date}}
        <br><br> {{isDefined}}
    </div>
    
    <!-- Script to uses angular.isDefined() function -->
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', function($scope) {
            $scope.date;
            $scope.isDefined =
            angular.isDefined($scope.date) == true ? 
            "$scope.date is defined." : "$scope.date is undefined.";
        }]);
    </script>
</body>
</html>

Output:

  • Date is not Defined:

isDefined

  • If Date is defined and its value is "2019-04-07T23:46:20.586":

isDate

Example 2: This example describes the usage of angular.isDefined() Function in AngularJS by specifying the current time.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>angular.isDefined()</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>
    <h3>angular.isDefined()</h3>
    <div ng-controller="geek"> 
        <b>Time:</b> {{ today| date : 'mediumTime'}}
        <br /><br /> {{isDefined}}
    </div>
    
    <!-- Script to uses angular.isDefined() function -->
    <script>
        var app = angular.module('app', []);
        app.controller('geek', ['$scope',
            function($scope) {
                $scope.today = new Date();
                $scope.isDefined = 
                angular.isDefined($scope.today) == true ?
                '$scope.date is defined.' : '$scope.date is undefined.';
            },
        ]);
    </script>
</body>
</html>

Output:

  • Time is not Defined:
 
  • When Time is defined:
 
Comment

Explore

    AngularJS Basics
    • AngularJS Tutorial3 min read
    • AngularJS Introduction4 min read
    • Angular CLI | Angular Project Setup3 min read
    • AngularJS Expressions2 min read
    • AngularJS Modules3 min read
    • AngularJS ng-model Directive4 min read
    • AngularJS Data Binding4 min read
    • AngularJS Controllers3 min read
    • AngularJS | Scope2 min read
    • AngularJS Services4 min read
    • AngularJS | AJAX - $http3 min read
    • AngularJS | Tables2 min read
    • AngularJS Select Boxes2 min read
    • AngularJS SQL3 min read
    • AngularJS HTML DOM2 min read
    • AngularJS Events3 min read
    • AngularJS | Forms3 min read
    • AngularJS Form Validation3 min read
    • AngularJS | API2 min read
    • AngularJS and W3.CSS2 min read
    • AngularJS Includes3 min read
    • AngularJS Animations1 min read
    • AngularJS | Application3 min read
    AngularJS Directives
    • AngularJS Directives9 min read
    • AngularJS ng-app Directive1 min read
    • AngularJS ng-bind Directive2 min read
    • AngularJS ng-bind-html Directive2 min read
    • AngularJS ng-bind-template Directive2 min read
    • AngularJS ng-blur Directive1 min read
    • AngularJS ng-change Directive2 min read
    • AngularJS ng-checked Directive2 min read
    • AngularJS ng-class Directive2 min read
    • AngularJS ng-class-even Directive2 min read
    • AngularJS ng-class-odd Directive2 min read
    • AngularJS ng-click Directive2 min read
    • AngularJS ng-cloak Directive2 min read
    • AngularJS ng-controller Directive2 min read
    • AngularJS Directives Complete Reference2 min read
    AngularJS Filters
    • AngularJS | Filters7 min read
    • AngularJS currency Filter2 min read
    • AngularJS | date Filter2 min read
    • AngularJS filter Filter3 min read
    • AngularJS json Filter2 min read
    • AngularJS limitTo Filter2 min read
    • AngularJS lowercase Filter1 min read
    • AngularJS number Filter1 min read
    • AngularJS orderBy Filter4 min read
    • AngularJs uppercase Filter1 min read
    AngularJS Converting Functions
    • AngularJS angular.lowercase() Function2 min read
    • AngularJS angular.uppercase() Function1 min read
    • AngularJS angular.forEach() Function1 min read
    AngularJS Comparing Functions
    • AngularJS angular.isArray() Function2 min read
    • AngularJS angular.isDate() Function2 min read
    • AngularJS angular.isDefined() Function2 min read
    • AngularJS angular.isElement() Function2 min read
    • AngularJS angular.isFunction() Function2 min read
    • AngularJS angular.isNumber() Function2 min read
    • AngularJS angular.isObject() Function2 min read
    • AngularJS | angular.isString() Function1 min read
    • AngularJS angular.isUndefined() Function2 min read
    • AngularJS angular.equals() Function2 min read
    • AngularJS angular.toJson() Function2 min read
    AngularJS Questions
    • How to bundle an Angular app for production?4 min read
    • How to add many functions in one ng-click directive?2 min read
    • How to directly update a field by using ng-click in AngularJS ?3 min read
    • How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ?3 min read
    • How to detect when an @Input() value changes in Angular?3 min read
    • How to open popup using Angular and Bootstrap ?2 min read
    • How to reload or re-render the entire page using AngularJS?2 min read
    • How to add input fields dynamically on button click in AngularJS ?2 min read
    • How to Create Button Dynamically with Click Event in Angular ?2 min read
    • How to use jQuery in Angular ?2 min read
    • AngularJS Examples2 min read
    Courses
    • MERN Full Stack Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.