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><scriptsrc="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script></head><bodyng-app="app"style="text-align:center"><h1style="color:green">
GeeksforGeeks
</h1><h3>angular.isDefined()</h3><divng-controller="geek"><b>Date:</b> {{date}}
<br><br> {{isDefined}}
</div><!-- Script to uses angular.isDefined() function --><script>varapp=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:
If Date is defined and its value is "2019-04-07T23:46:20.586":
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><scriptsrc="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script></head><bodyng-app="app"style="text-align: center"><h1style="color: green">GeeksforGeeks</h1><h3>angular.isDefined()</h3><divng-controller="geek"><b>Time:</b> {{ today| date : 'mediumTime'}}
<br/><br/> {{isDefined}}
</div><!-- Script to uses angular.isDefined() function --><script>varapp=angular.module('app',[]);app.controller('geek',['$scope',function($scope){$scope.today=newDate();$scope.isDefined=angular.isDefined($scope.today)==true?'$scope.date is defined.':'$scope.date is undefined.';},]);</script></body></html>
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.