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 a defined otherwise returns false.
Syntax:
angular.isDefined( value )
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.
<!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> <h2>angular.isDefined()</h2> <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 not Defined:

- If Date is defined and its value is “2019-04-07T23:46:20.586”:

Recommended Posts:
- AngularJS | angular.bootstrap() Function
- AngularJS | angular.isFunction() Function
- AngularJS | angular.element() Function
- AngularJS | angular.toJson() Function
- AngularJS | angular.isDate() Function
- AngularJS | angular.isElement() Function
- AngularJS | angular.bind() Function
- AngularJS | angular.forEach() Function
- AngularJS | angular.isArray() Function
- AngularJS | angular.equals() Function
- AngularJS | angular.isNumber() Function
- AngularJS | angular.isUndefined() Function
- AngularJS | angular.isObject() Function
- AngularJS | angular.uppercase() Function
- AngularJS | angular.isString() Function
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.



