angular.isUndefined: This function is used to check undefined variable in AngularJs. The function angular.isUndefined will return true if passed variable is undefined else it will return false. Here in this tutorial we are going to explain how you can use this function to determine a undefined variable in AngularJs. You can use our online editor to edit and run the code online.
angular.isUndefined – AngularJs check undefined value | Example
Sytax for angular.isUndefined is as below-
Syntax –
angular.isUndefined Syntax
angular.isUndefined(value); |
The above function checks whether the passed variable is undefined or not and on the basis of that it returns true or false.
Arguments
- value : This is reference to check.
Returns
- boolean : Returns true if reference is not defined ie. undefined else it will return false.
Now let us create a simple example to understand the above function.
Example
AngularJs check undefined value | Variable Example
<div ng-app="myApp"> <div ng-controller="myController"> <button ng-click="chackVars()">Check Vars</button> <br/> Result for a = {{result1}}<br/> Result for b = {{result2}} </div> </div> |
If you run the above example it will produce the output something like this –